From b4eeaa63f1c5f1a373d79205e6a49f3fc302514e Mon Sep 17 00:00:00 2001 From: Eric Martindale Date: Wed, 18 Mar 2015 15:28:04 -0400 Subject: [PATCH] Fix updates, albeit not optimally. --- lib/Resource/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Resource/index.js b/lib/Resource/index.js index 72a324b0..19544b0b 100644 --- a/lib/Resource/index.js +++ b/lib/Resource/index.js @@ -419,14 +419,19 @@ Resource.prototype.update = function( query , params , complete ) { if (!complete) var complete = new Function(); if (!query) return complete('no query'); - Model.findOneAndUpdate( query ).exec(function(err, doc) { + Model.findOne( query ).exec(function(err, doc) { if (err) return complete( err ); if (!doc) return complete( 404 ); + + Object.keys( params ).forEach(function(p) { + doc[ p ] = params[ p ]; + }); - // TODO: consider offering a changeset. - self.emit('update', doc ); - complete( err , doc ); - + doc.save(function() { + // TODO: consider offering a changeset. + self.emit('update', doc ); + complete( err , doc ); + }); }); }