Beautifully straight forward NoSQL JSON document DB.
npm install nosqldbBeautifully straight forward NoSQL JSON document DB.
!npm monthly downloads
!github release
!github license
npm install nosqldb --save`
2. Create any new data collection with `var users = require('nosqldb')('users')`
3. Run your node app. That's it!$3
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' })`.$3
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.
$3
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.$3
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.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