|
|
@ -425,7 +425,7 @@ Datastore.prototype.insert = function () { |
|
|
|
* Find all documents matching the query |
|
|
|
* Find all documents matching the query |
|
|
|
* @param {Object} query MongoDB-style query |
|
|
|
* @param {Object} query MongoDB-style query |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Datastore.prototype.find = function (query, callback) { |
|
|
|
Datastore.prototype._find = function (query, callback) { |
|
|
|
var res = [] |
|
|
|
var res = [] |
|
|
|
, self = this |
|
|
|
, self = this |
|
|
|
, candidates = this.getCandidates(query) |
|
|
|
, candidates = this.getCandidates(query) |
|
|
@ -445,12 +445,16 @@ Datastore.prototype.find = function (query, callback) { |
|
|
|
return callback(null, res); |
|
|
|
return callback(null, res); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Datastore.prototype.find = function () { |
|
|
|
|
|
|
|
this.executor.push({ this: this, fn: this._find, arguments: arguments }); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Find one document matching the query |
|
|
|
* Find one document matching the query |
|
|
|
* @param {Object} query MongoDB-style query |
|
|
|
* @param {Object} query MongoDB-style query |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Datastore.prototype.findOne = function (query, callback) { |
|
|
|
Datastore.prototype._findOne = function (query, callback) { |
|
|
|
var self = this |
|
|
|
var self = this |
|
|
|
, candidates = this.getCandidates(query) |
|
|
|
, candidates = this.getCandidates(query) |
|
|
|
, i |
|
|
|
, i |
|
|
@ -469,6 +473,10 @@ Datastore.prototype.findOne = function (query, callback) { |
|
|
|
return callback(null, null); |
|
|
|
return callback(null, null); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Datastore.prototype.findOne = function () { |
|
|
|
|
|
|
|
this.executor.push({ this: this, fn: this._findOne, arguments: arguments }); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Update all docs matching query |
|
|
|
* Update all docs matching query |
|
|
@ -501,7 +509,7 @@ Datastore.prototype._update = function (query, updateQuery, options, cb) { |
|
|
|
function (cb) { // If upsert option is set, check whether we need to insert the doc
|
|
|
|
function (cb) { // If upsert option is set, check whether we need to insert the doc
|
|
|
|
if (!upsert) { return cb(); } |
|
|
|
if (!upsert) { return cb(); } |
|
|
|
|
|
|
|
|
|
|
|
self.findOne(query, function (err, doc) { |
|
|
|
self._findOne(query, function (err, doc) { |
|
|
|
if (err) { return callback(err); } |
|
|
|
if (err) { return callback(err); } |
|
|
|
if (doc) { |
|
|
|
if (doc) { |
|
|
|
return cb(); |
|
|
|
return cb(); |
|
|
|