Browser-specific persistence module

pull/2/head
Louis Chatriot 12 years ago
parent 4284c8b567
commit 438156bdd0
  1. 0
      browser-version/browser-specific/lib/customUtils.js
  2. 40
      browser-version/browser-specific/lib/persistence.js
  3. 2
      lib/persistence.js

@ -0,0 +1,40 @@
/**
* 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;

@ -171,8 +171,6 @@ Persistence.treatRawData = function (rawData) {
* Also, all data is persisted right away, which has the effect of compacting the database file * Also, all data is persisted right away, which has the effect of compacting the database file
* This operation is very quick at startup for a big collection (60ms for ~10k docs) * This operation is very quick at startup for a big collection (60ms for ~10k docs)
* @param {Function} cb Optional callback, signature: err * @param {Function} cb Optional callback, signature: err
*
* @api private Use loadDatabase
*/ */
Persistence.prototype.loadDatabase = function (cb) { Persistence.prototype.loadDatabase = function (cb) {
var callback = cb || function () {} var callback = cb || function () {}

Loading…
Cancel
Save