mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-15 17:47:51 +08:00
fixed error message for atomic PUTs
This commit is contained in:
@@ -388,6 +388,9 @@ Collection.prototype.save = function (session, item, query, client, fn) {
|
||||
if(query.id) {
|
||||
// is PUT
|
||||
store.first({id: query.id, $fields: query.$fields}, function(err, obj) {
|
||||
if(!obj) return fn(new Error('You can\'t update an object that does not exist.'));
|
||||
if(err) return fn(rerr);
|
||||
|
||||
// merge changes
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
if(!item[key]) item[key] = obj[key];
|
||||
@@ -402,7 +405,6 @@ Collection.prototype.save = function (session, item, query, client, fn) {
|
||||
err.message = 'Error while executing PUT event: ' + err.message;
|
||||
return fn(err);
|
||||
}
|
||||
if(!obj) return fn(new Error('You can\'t update an object by ID that does not exist.'));
|
||||
|
||||
delete item.id;
|
||||
store.update(query, item, function (err) {
|
||||
|
||||
Reference in New Issue
Block a user