|
|
|
@ -3,7 +3,7 @@ var fs = require('fs') |
|
|
|
|
, customUtils = require('./customUtils') |
|
|
|
|
, model = require('./model') |
|
|
|
|
, async = require('async') |
|
|
|
|
, executor = require('./executor') |
|
|
|
|
, Executor = require('./executor') |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -13,6 +13,7 @@ var fs = require('fs') |
|
|
|
|
function Datastore (filename) { |
|
|
|
|
this.filename = filename; |
|
|
|
|
this.data = []; |
|
|
|
|
this.executor = new Executor(); |
|
|
|
|
|
|
|
|
|
// We keep internally the number of lines in the datafile
|
|
|
|
|
// This will be used when/if I implement autocompacting when the datafile grows too big
|
|
|
|
@ -53,7 +54,7 @@ Datastore.prototype._loadDatabase = function (cb) { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Datastore.prototype.loadDatabase = function () { |
|
|
|
|
executor.push({ this: this, fn: this._loadDatabase, arguments: arguments }); |
|
|
|
|
this.executor.push({ this: this, fn: this._loadDatabase, arguments: arguments }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -143,7 +144,7 @@ Datastore.prototype._insert = function (newDoc, cb) { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Datastore.prototype.insert = function () { |
|
|
|
|
executor.push({ this: this, fn: this._insert, arguments: arguments }); |
|
|
|
|
this.executor.push({ this: this, fn: this._insert, arguments: arguments }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -285,7 +286,7 @@ Datastore.prototype._update = function (query, updateQuery, options, cb) { |
|
|
|
|
]); |
|
|
|
|
}; |
|
|
|
|
Datastore.prototype.update = function () { |
|
|
|
|
executor.push({ this: this, fn: this._update, arguments: arguments }); |
|
|
|
|
this.executor.push({ this: this, fn: this._update, arguments: arguments }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -332,7 +333,7 @@ Datastore.prototype._remove = function (query, options, cb) { |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
Datastore.prototype.remove = function () { |
|
|
|
|
executor.push({ this: this, fn: this._remove, arguments: arguments }); |
|
|
|
|
this.executor.push({ this: this, fn: this._remove, arguments: arguments }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|