|
|
@ -395,20 +395,20 @@ Datastore.prototype.find = function () { |
|
|
|
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, found = null |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
for (i = 0; i < candidates.length; i += 1) { |
|
|
|
for (i = 0; i < candidates.length; i += 1) { |
|
|
|
if (model.match(candidates[i], query)) { |
|
|
|
if (model.match(candidates[i], query)) { |
|
|
|
return callback(null, model.deepCopy(candidates[i])); |
|
|
|
found = model.deepCopy(candidates[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
return callback(err); |
|
|
|
return callback(err); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return callback(null, null); |
|
|
|
return callback(null, found); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Datastore.prototype.findOne = function () { |
|
|
|
Datastore.prototype.findOne = function () { |
|
|
@ -472,7 +472,7 @@ Datastore.prototype._update = function (query, updateQuery, options, cb) { |
|
|
|
if (model.match(candidates[i], query) && (multi || numReplaced === 0)) { |
|
|
|
if (model.match(candidates[i], query) && (multi || numReplaced === 0)) { |
|
|
|
numReplaced += 1; |
|
|
|
numReplaced += 1; |
|
|
|
modifiedDoc = model.modify(candidates[i], updateQuery); |
|
|
|
modifiedDoc = model.modify(candidates[i], updateQuery); |
|
|
|
modifications.push({ oldDoc: candidates[i], newDoc: modifiedDoc }); |
|
|
|
modifications.push({ oldDoc: candidates[i], newDoc: modifiedDoc }); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
@ -542,5 +542,4 @@ Datastore.prototype.remove = function () { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = Datastore; |
|
|
|
module.exports = Datastore; |