From b0d29584d388ad184434212fce354379ab2f2cbd Mon Sep 17 00:00:00 2001 From: Tristan Cavelier <tristan.cavelier@tiolive.com> Date: Fri, 5 Jul 2013 15:46:03 +0200 Subject: [PATCH] splitstorage.js bug: post update existent document -> fixed --- src/jio.storage/splitstorage.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/jio.storage/splitstorage.js b/src/jio.storage/splitstorage.js index 6615cea..984dfb9 100644 --- a/src/jio.storage/splitstorage.js +++ b/src/jio.storage/splitstorage.js @@ -334,8 +334,9 @@ * @private * @param {Object} doc A serialized document object * @param {Object} option Command option properties + * @param {String} method The command method ('post' or 'put') */ - priv.postOrPut = function (doc, option) { + priv.postOrPut = function (doc, option, method) { var i, data, doc_list = [], doc_underscores = {}; if (!doc._id) { doc._id = generateUuid(); @@ -356,9 +357,9 @@ (data.length / priv.storage_list.length) * (i + 1) ); } - priv.send('put', doc_list, option, function (err, response) { + priv.send(method, doc_list, option, function (err, response) { if (err) { - err.message = "Unable to post document"; + err.message = "Unable to " + method + " document"; delete err.index; return that.error(err); } @@ -376,7 +377,7 @@ * @param {Command} command The JIO command */ that.post = function (command) { - priv.postOrPut(command.cloneDoc(), command.cloneOption()); + priv.postOrPut(command.cloneDoc(), command.cloneOption(), 'post'); }; /** @@ -386,7 +387,7 @@ * @param {Command} command The JIO command */ that.put = function (command) { - priv.postOrPut(command.cloneDoc(), command.cloneOption()); + priv.postOrPut(command.cloneDoc(), command.cloneOption(), 'put'); }; /** -- 2.30.9