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

browsedb

v1.1.2

Published

BrowseDB is a javascript clientside library for managing localStorage data in mongoose style.

Downloads

15

Readme

Visit Site For more Docs

🔗Description

BrowseDB is a JavaScript clientside library for managing localStorage data in mongoose style. BrowseDB provides its users, methods for managing localStorage data efficiently. It can be used for simple CRUD operations. BrowseDB's data is stored in string format but all data operations are done in JSON format.

📕 Terminologies

Collections - All BrowseDB instances are called collections, as they are just collections(arrays) of objects(documents).

Documents - As you might have guessed, are simply objects.

Schema - A schema is simply an object that describes the expected structure or blueprint of documents of a particular collection. This could be used for some sort of type checking. It is optional.

⚙️Usage and Settings

First, to use browsedb. Include/import browsedb, then create an instance of browsedb. Example

    const schema = {
        text: {
            type: String,
            required: true
        },
        done: Boolean,
        date: {
            type: Number,
            required: true,
            default: Date.now
        }
    };
    const todos = new BrowseDB("todos", schema);

Methods

  • create - Used for creating documents. It accepts an object containing required data for object creation and returns a copy of the new document inserted into localStorage with its ID. BrowseDB generates a unique ID for the newly inserted document.
    todos.create({ text: "Learn BrowseDB", done: false });
  • find - For finding documents. It accepts two optional parameters: query and key. query is used in similar fashion to 'WHERE' in SQL like databases, While key is used for filtering results. Example
    todos.find(); // Returns all documents
    todos.find({}) // Returns all documents
    todos.find({ done: true }); // Returns all documents where done equal true
    todos.find({ done: false }, {done: 0, id: 0}); // Returns documents where done equal false but doesn't show done and id's of each document.
  • findById - For finding documents based on id. It accepts one parameter: id. id(string) represents id of a document. It returns a document with the passed id.
    todos.findById("zUVxUed827"); // Returns Document with id 'zUVxUed827'
  • update - For updating data in document(s). It accepts two parameters: query and data. Here, query is used as 'WHERE' would be used Relational databases, while data represents the new data to be put into selected documents. The below example will find all documents where done = false, and update the text field.
    todos.update({done: false}, {text: "Todo is not yet done"});
  • updateById - For updating data in a document based on id. It finds a document by id, updates its content and returns the updated content. It accepts two parameters: id and data.

  • updateAll - For updating all documents data at once. It accepts one parameter: data.

  • delete - Finds and deletes documents. Accepts one parameter: query - Where the delete operation should take place.

  • deleteById - Finds, deletes and returns a document with id passed to it. Accepts one parameter id.

  • deleteAll - Deletes all documents in a collection.

  • remove - This function is a bit similar in behaviour to delete.

Installation

Content Delivery Networks

CDN Link https://unpkg.com/[email protected]/browsedb.min.js

HTML Tag

    <script src="https://unpkg.com/[email protected]/browsedb.min.js"><script>

Using NPM

    npm install browsedb

⛏️Development

  • yarn build or npm run build - produces a production version of library under the lib folder

⭐️Show your support

Please star this repository if this project helped you!

👋 Contributing

Please read the CONTRIBUTING.md file to see how to contribute.

🌤️Browser compatibility

Browsedb works across all browsers that support localStorage. You could check for compatibility here:

  • https://caniuse.com/#search=localStorage