Skip to content

Commit

Permalink
fix breaking changes introduced by mongodb update
Browse files Browse the repository at this point in the history
  • Loading branch information
zemirco committed Jul 3, 2015
1 parent c33ec04 commit 95cba4f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ Adapter.prototype.save = function(name, email, pw, done) {
if (err) {return done(err); }
user.salt = salt;
user.derived_key = hash;
that.db.collection(that.collection).save(user, done);
that.db.collection(that.collection).save(user, function(saveErr, result) {
done(saveErr, result.ops[0]);
});
});
};

Expand Down Expand Up @@ -172,9 +174,9 @@ Adapter.prototype.update = function(user, done) {
* @param {Function} done - Callback function `function(err, res){}`
*/
Adapter.prototype.remove = function(name, done) {
this.db.collection(this.collection).remove({name: name}, function(err, numberOfRemovedDocs) {
this.db.collection(this.collection).remove({name: name}, function(err, result) {
if (err) {return done(err); }
if (numberOfRemovedDocs === 0) {return done(new Error('lockit - Cannot find user "' + name + '"')); }
if (result.result.n === 0) {return done(new Error('lockit - Cannot find user "' + name + '"')); }
done(null, true);
});
};

0 comments on commit 95cba4f

Please sign in to comment.