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

nosqldb

v0.1.6

Published

Beautifully straight forward NoSQL JSON document DB.

Downloads

4

Readme

Beautifully straight forward NoSQL JSON document DB.

NoSQL DB

npm monthly downloads github release github license

npm install nosqldb --save

Background

This project came from wanting the flexibility in a NoSQL DB syntax, but without the bloat of having an extra database service starting in the background. Sometimes, you just want to store JSON data in a local file, and have intuitive methods that help you store and retrive that data. This's exactly what NoSQL DB does.

Getting Started

Super straightforward. Here are the few steps:

  1. Bring NoSQL DB into your project with npm install nosqldb --save
  2. Create any new data collection with var users = require('nosqldb')('users')
  3. Run your node app. That's it!

Specifying Primary Key

Instead of using the default id primary key, you can pass any string to define your primary key. So if you wanted your users object to have a primary key of user_id, simply var users = require('nosqldb')('users', { primaryKey: 'user_id' }).

API

With each new data collection, you get a series of helpers that easily get your data in and out from local storage. So for clarity, if you var users = require('nosqldb')('users'), these methods are called on your users object.

.all()

Takes no parameters, simply returns all rows in your collection.

.saveItem(item)

Takes an item object, where keys and values are defined. This object will be appended to your collection.

.saveItems(item, item2, item3 ...)

Takes unlimited item objects as parameters, where each item's keys and values are defined. Each item is consecutively appended to your collection.

.create(item, item2, item3 ...)

Alias of saveItems.

.makeEmpty()

Takes no parameters, removes all rows and empties your collection.

.where(predicate)

Takes a predicate, where keys and values are defined. Only rows matching all keys and values in your predicate will be returned.

.findWhere(predicate)

Takes a predicate, where keys and values are defined. Only the first row matching all keys and values in your predicate will be returned.

.deleteWhere(predicate)

Takes a predicate, where keys and values are defined. Only rows matching all keys and values in your predicate will be removed from your collection.

.delete(predicate)

Alias of deleteWhere.

.keepWhere(predicate)

Takes a predicate, where keys and values are defined. Only rows matching all keys and values in your predicate will be saved in your collection. All other rows will be removed from your collection.

.keep(predicate)

Alias of keepWhere.

.updateWhere(predicate, updatedValues)

Takes a predicate and updatedValues, where each has keys and values defined. Only rows matching all keys and values in your predicate will be updated in your collection.

.update(predicate, updatedValues)

Alias of updateWhere.

Primary Key

By default, the primary key is simply id and NoSQL DB auto-generates that identifier for each row (or JSON document). Alternatively, you have the option of overriding the auto-generated identifier. Simply pass your own value for the id parameter in any document save or update method.

Document Hashing

By default, NoSQL DB auto-generates that identifier as a unique hash to that object. That means NoSQL DB maintains unique records for you, right out-the-box. Alternatively, you have the option of overriding this feature. Simply pass the string 'nonunique' for the id parameter in any document save method. This gets you non-unique records in your collection anytime.

Quick Notes

Currently, there's no chaining of methods. Also, you can't use any RegEx in your predicates. These are features that I'll be adding going forward, that is if people are wanting those features.

Also, this modules relies on Node's native fs module. So don't try running this in the browser or in any environment where Node's native fs module doesn't work. Again I'd love to add a browser port, maybe using Google's Level but only if people are wanting that in this project ;)

Happy coding! HQ