|
|
@ -590,7 +590,7 @@ Datastore.prototype._update = function (query, updateQuery, options, cb) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
, function () { // Perform the update
|
|
|
|
, function () { // Perform the update
|
|
|
|
var modifiedDoc , modifications = []; |
|
|
|
var modifiedDoc , modifications = [], createdAt; |
|
|
|
|
|
|
|
|
|
|
|
self.getCandidates(query, function (err, candidates) { |
|
|
|
self.getCandidates(query, function (err, candidates) { |
|
|
|
if (err) { return callback(err); } |
|
|
|
if (err) { return callback(err); } |
|
|
@ -601,8 +601,12 @@ Datastore.prototype._update = function (query, updateQuery, options, cb) { |
|
|
|
for (i = 0; i < candidates.length; i += 1) { |
|
|
|
for (i = 0; i < candidates.length; i += 1) { |
|
|
|
if (model.match(candidates[i], query) && (multi || numReplaced === 0)) { |
|
|
|
if (model.match(candidates[i], query) && (multi || numReplaced === 0)) { |
|
|
|
numReplaced += 1; |
|
|
|
numReplaced += 1; |
|
|
|
|
|
|
|
if (self.timestampData) { createdAt = candidates[i].createdAt; } |
|
|
|
modifiedDoc = model.modify(candidates[i], updateQuery); |
|
|
|
modifiedDoc = model.modify(candidates[i], updateQuery); |
|
|
|
if (self.timestampData) { modifiedDoc.updatedAt = new Date(); } |
|
|
|
if (self.timestampData) { |
|
|
|
|
|
|
|
modifiedDoc.createdAt = createdAt; |
|
|
|
|
|
|
|
modifiedDoc.updatedAt = new Date(); |
|
|
|
|
|
|
|
} |
|
|
|
modifications.push({ oldDoc: candidates[i], newDoc: modifiedDoc }); |
|
|
|
modifications.push({ oldDoc: candidates[i], newDoc: modifiedDoc }); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|