The JavaScript Database, for Node.js, nw.js, electron and the browser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
nedb/browser-version/browser-specific/lib/persistence.js

40 lines
974 B

/**
* Handle every persistence-related task
* The interface Datastore expects to be implemented is
* * Persistence.loadDatabase(callback) and callback has signature err
* * Persistence.persistNewState(newDocs, callback) where newDocs is an array of documents and callback has signature err
*
* Shim for the browser
*/
/**
* Create a new Persistence object for database options.db
* For now, no browser persistence supported, in-memory only mode forced
* @param {Datastore} options.db
*/
function Persistence (options) {
this.db = options.db;
this.db.inMemoryOnly = true;
this.db.filename = null;
this.inMemoryOnly = true;
};
/**
* No persistence in the browser (for now)
*/
Persistence.prototype.persistNewState = function (newDocs, cb) {
if (cb) { return cb(); }
};
/**
* No persistence in the browser (for now)
*/
Persistence.prototype.loadDatabase = function (cb) {
if (cb) { return cb(); }
};
// Interface
module.exports = Persistence;