npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flexdb

v0.4.0

Published

FlexDB is a flexible, free-to-use database service that allows for instant and seamless integration through its REST API. This library, `flexdb`, provides an easy-to-use wrapper around the [FlexDB](https://flexdb.co) REST API.

Downloads

5

Readme

FlexDB

FlexDB is a flexible, free-to-use database service that allows for instant and seamless integration through its REST API. This library, flexdb, provides an easy-to-use wrapper around the FlexDB REST API.

github stars npm version npm downloads license

Installation

To start using FlexDB in your project, simply run the following command:

npm install flexdb

Usage

Importing the library

First, let's import the FlexDB class from the flexdb package:

import { FlexDB } from 'flexdb'

Initialize FlexDB

Now, create a new instance of the FlexDB class.

const flexdb = new FlexDB()

You can pass an optional configuration object containing your API key and the API endpoint:

const flexdb = new FlexDB({ apiKey: 'your_api_key' })

Create a store

A store is like a container for your data. To create a new store, call the createStore method with a unique name:

const store = await flexdb.createStore('my-store')

Get a store

To fetch an existing store by its name (when using an API key), use the getStore method:

const store = await flexdb.getStore('my-store')

Ensure a store exists

If you want to make sure a store exists before performing any operations, use the ensureStoreExists method. It will return the existing store or create a new one if it doesn't exist:

const store = await flexdb.ensureStoreExists('my-store')

Create a collection

A collection is a group of related documents within a store. To create a new collection, call the collection method on a store instance:

const collection = store.collection('my-collection')

Create a document

To add a new document to a collection, use the create method and pass an object containing the data you want to store:

const document = await collection.create({ key: 'value' })

Get a document

To fetch a document by its ID, use the get method:

const document = await collection.get('document_id')

Update a document

To update an existing document, call the update method with the document ID and an object containing the updated data:

const updatedDocument = await collection.update('document_id', { key: 'new_value' })

Delete a document

To remove a document from a collection, use the delete method and pass the document ID:

await collection.delete('document_id')

Get many documents

To fetch multiple documents from a collection, use the getMany method. You can pass an options object to control pagination and the number of documents to fetch:

const documents = await collection.getMany({ page: 1, limit: 10 })

Delete a collection

To remove an entire collection and all its documents, call the deleteCollection method:

await collection.deleteCollection()

Delete a store

To delete a store and all its collections, use the delete method on a store instance:

await store.delete()

License

This project is licensed under the GPL-3.0 License - see the LICENSE.md file for details.