|
|
|
@ -97,7 +97,7 @@ Datastore.prototype.ensureIndex = function (options, cb) { |
|
|
|
|
options = options || {}; |
|
|
|
|
|
|
|
|
|
if (!options.fieldName) { return callback({ missingFieldName: true }); } |
|
|
|
|
if (this.indexes[options.fieldName]) { return callback(); } |
|
|
|
|
if (this.indexes[options.fieldName]) { return callback(null); } |
|
|
|
|
|
|
|
|
|
this.indexes[options.fieldName] = new Index(options); |
|
|
|
|
|
|
|
|
@ -108,7 +108,7 @@ Datastore.prototype.ensureIndex = function (options, cb) { |
|
|
|
|
return callback(e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return callback(); |
|
|
|
|
return callback(null); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -253,7 +253,7 @@ Datastore.prototype._loadDatabase = function (cb) { |
|
|
|
|
self.datafileSize = 0; |
|
|
|
|
|
|
|
|
|
// In-memory only datastore
|
|
|
|
|
if (self.inMemoryOnly) { return callback(); } |
|
|
|
|
if (self.inMemoryOnly) { return callback(null); } |
|
|
|
|
|
|
|
|
|
customUtils.ensureDirectoryExists(path.dirname(self.filename), function (err) { |
|
|
|
|
fs.exists(self.filename, function (exists) { |
|
|
|
@ -336,7 +336,7 @@ Datastore.prototype.persistCachedDatabase = function (cb) { |
|
|
|
|
toPersist += model.serialize(doc) + '\n'; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (toPersist.length === 0) { return callback(); } |
|
|
|
|
if (toPersist.length === 0) { return callback(null); } |
|
|
|
|
|
|
|
|
|
fs.writeFile(this.filename, toPersist, function (err) { return callback(err); }); |
|
|
|
|
}; |
|
|
|
@ -355,7 +355,7 @@ Datastore.prototype._persistNewState = function (newDocs, cb) { |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
// In-memory only datastore
|
|
|
|
|
if (self.inMemoryOnly) { return callback(); } |
|
|
|
|
if (self.inMemoryOnly) { return callback(null); } |
|
|
|
|
|
|
|
|
|
self.datafileSize += newDocs.length; |
|
|
|
|
|
|
|
|
@ -363,7 +363,7 @@ Datastore.prototype._persistNewState = function (newDocs, cb) { |
|
|
|
|
toPersist += model.serialize(doc) + '\n'; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (toPersist.length === 0) { return callback(); } |
|
|
|
|
if (toPersist.length === 0) { return callback(null); } |
|
|
|
|
|
|
|
|
|
fs.appendFile(self.filename, toPersist, 'utf8', function (err) { |
|
|
|
|
return callback(err); |
|
|
|
|