From bf0a0c8547a5202168c681554f28a6c7c861b2c0 Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Mon, 2 Sep 2013 20:09:34 +0200 Subject: [PATCH] If a multi update fails on one docs, the others shouldnt be changed --- lib/datastore.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/datastore.js b/lib/datastore.js index 3d167e7..6d0ed4a 100644 --- a/lib/datastore.js +++ b/lib/datastore.js @@ -427,12 +427,14 @@ Datastore.prototype._update = function (query, updateQuery, options, cb) { return callback(err); } + // Change the docs in memory try { self.updateIndexes(modifications); } catch (err) { return callback(err); } + // Update the datafile self.persistence.persistNewState(_.pluck(modifications, 'newDoc'), function (err) { if (err) { return callback(err); } return callback(null, numReplaced);