|
|
@ -390,8 +390,14 @@ Datastore.prototype.count = function() { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Datastore.prototype.find = function (query, callback) { |
|
|
|
Datastore.prototype.find = function (query, callback) { |
|
|
|
var cursor = new Cursor(this, query, function(err, docs, callback) { |
|
|
|
var cursor = new Cursor(this, query, function(err, docs, callback) { |
|
|
|
|
|
|
|
var res = [], i; |
|
|
|
|
|
|
|
|
|
|
|
if (err) { return callback(err); } |
|
|
|
if (err) { return callback(err); } |
|
|
|
return callback(null, docs); |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < docs.length; i += 1) { |
|
|
|
|
|
|
|
res.push(model.deepCopy(docs[i])); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return callback(null, res); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (typeof callback === 'function') { |
|
|
|
if (typeof callback === 'function') { |
|
|
@ -410,7 +416,7 @@ Datastore.prototype.findOne = function (query, callback) { |
|
|
|
var cursor = new Cursor(this, query, function(err, docs, callback) { |
|
|
|
var cursor = new Cursor(this, query, function(err, docs, callback) { |
|
|
|
if (err) { return callback(err); } |
|
|
|
if (err) { return callback(err); } |
|
|
|
if (docs.length === 1) { |
|
|
|
if (docs.length === 1) { |
|
|
|
return callback(null, docs[0]); |
|
|
|
return callback(null, model.deepCopy(docs[0])); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return callback(null, null);
|
|
|
|
return callback(null, null);
|
|
|
|
} |
|
|
|
} |
|
|
|