1.0.6 • Published 8 years ago

nedb-wrapper v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

nedb-wrapper

Needed to use NeDB but didn't want to bother with setup all the time.

Also modified .remove and .update to fit my needs.

Installation

npm install --save nedb-wrapper

Usage

var Storage = require('nedb-wrapper')
var storage = new Storage(); //defaults to ./db/local-storage.db

//var storage = new Storage('./path/storage.db)
//var storage = new Storage(null, true)  for in-memory only
//var storage = new Storage(null, false, onload)  to add onload listener
//function onload(err){};

Currently includes as-is from NeDB:

  • .find
  • .findOne
  • .insert

All original functionalities can be accessed with ._datastore

Modified Functionalities

.update(doc, cb)

//@doc - updated document; must have _id
var input = {
  _id: '1232334',
  value: 5
}
storage.update(input, function(err, result){
  if(err) return;
  //result is identical to input in this case
  //do stuff to result
}

.remove(doc, cb)

//@doc - document to delete; requires _id; ignores the rest
var input = {
  _id: '1232334',
  value: 5
}
storage.update(input, function(err, result){
  if(err) return;
  //result is identical to input in this case
  //result is number of deleted documents; always 1, hopefully
}
1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago