Database loading needs to be sequential too

pull/2/head
Louis Chatriot 12 years ago
parent 31e53b3007
commit 688c35b08b
  1. 7
      lib/datastore.js
  2. 6
      test/db.test.js

@ -27,8 +27,10 @@ function Datastore (filename) {
* For now this means pulling data out of the data file or creating it * For now this means pulling data out of the data file or creating it
* if it doesn't exist * if it doesn't exist
* @param {Function} cb Optional callback, signature: err * @param {Function} cb Optional callback, signature: err
*
* @api private
*/ */
Datastore.prototype.loadDatabase = function (cb) { Datastore.prototype._loadDatabase = function (cb) {
var callback = cb || function () {} var callback = cb || function () {}
, self = this , self = this
; ;
@ -49,6 +51,9 @@ Datastore.prototype.loadDatabase = function (cb) {
}); });
}; };
Datastore.prototype.loadDatabase = function () {
executor.push({ this: this, fn: this._loadDatabase, arguments: arguments });
};
/** /**
* From a database's raw data, return the corresponding * From a database's raw data, return the corresponding

@ -36,7 +36,7 @@ describe('Database', function () {
}); });
describe.only('Loading the database data from file', function () { describe('Loading the database data from file', function () {
it('Every line represents a document', function () { it('Every line represents a document', function () {
var now = new Date() var now = new Date()
@ -65,6 +65,10 @@ describe('Database', function () {
_.isEqual(treatedData[1], { nested: { today: now } }).should.equal(true); _.isEqual(treatedData[1], { nested: { today: now } }).should.equal(true);
}); });
it('Documents with', function () {
});
}); // ==== End of 'Loading the database data from file' ==== // }); // ==== End of 'Loading the database data from file' ==== //

Loading…
Cancel
Save