https://github.com/louischatriot/nedb
终于让我给盼到了, Up!
// In-memory only datastore
var Datastore = require('nedb')
, db = new Datastore();
// Persistent datastore
var Datastore = require('nedb')
, db = new Datastore({ filename: 'path/to/datafile' });
// Persistent datastore for a Node Webkit app called 'nwtest'
// For example on Linux, the datafile will be ~/.config/nwtest/nedb-data/something.db
var Datastore = require('nedb')
, db = new Datastore({ filename: 'something.db', nodeWebkitAppName: 'nwtest' });
db.loadDatabase(function (err) { // Callback is optional
// err is the error, if any
});
// Of course you can create multiple datastores if you need several
// collections. For example:
db = {};
db.users = new Datastore('path/to/users.db');
db.robots = new Datastore('path/to/robots.db');
// You need to load each database (here we do it asynchronously)
db.users.loadDatabase();
db.robots.loadDatabase();