Commit b0d29584 authored by Tristan Cavelier's avatar Tristan Cavelier

splitstorage.js bug: post update existent document -> fixed

parent 6ca268a2
...@@ -334,8 +334,9 @@ ...@@ -334,8 +334,9 @@
* @private * @private
* @param {Object} doc A serialized document object * @param {Object} doc A serialized document object
* @param {Object} option Command option properties * @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 = {}; var i, data, doc_list = [], doc_underscores = {};
if (!doc._id) { if (!doc._id) {
doc._id = generateUuid(); doc._id = generateUuid();
...@@ -356,9 +357,9 @@ ...@@ -356,9 +357,9 @@
(data.length / priv.storage_list.length) * (i + 1) (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) { if (err) {
err.message = "Unable to post document"; err.message = "Unable to " + method + " document";
delete err.index; delete err.index;
return that.error(err); return that.error(err);
} }
...@@ -376,7 +377,7 @@ ...@@ -376,7 +377,7 @@
* @param {Command} command The JIO command * @param {Command} command The JIO command
*/ */
that.post = function (command) { that.post = function (command) {
priv.postOrPut(command.cloneDoc(), command.cloneOption()); priv.postOrPut(command.cloneDoc(), command.cloneOption(), 'post');
}; };
/** /**
...@@ -386,7 +387,7 @@ ...@@ -386,7 +387,7 @@
* @param {Command} command The JIO command * @param {Command} command The JIO command
*/ */
that.put = function (command) { that.put = function (command) {
priv.postOrPut(command.cloneDoc(), command.cloneOption()); priv.postOrPut(command.cloneDoc(), command.cloneOption(), 'put');
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment