When using this user.meta.logins.$inc(); I get this error in the console:
Mongoose MongooseNumber#$inc / MongooseNumber#increment is deprecated.
Use Model.update() to get incrementation in v3 instead.
What I have beed doing is this (code is stripped down to the basic usage):
userSchema.methods = {
userFind : function (user, pass, callback) {
this.model('user').findOne({ 'username':user, 'password':pass }, callback);
}
}
var userModel = new model();
userModel.userFind(username, password, function(err, user) {
user.meta.logins.$inc();
user.meta.last_action = new Date();
user.save();
});
This works just fine but since the deprecation is at hand, I want to use the proposed Model.update() method to update the user, however I can’t make it happen.
I have tried doing userModel.update() and user.update() but in both cases I get errors. Maybe my syntax is wrong for the update.
Any ideas would be much appreciated.
To use
updatefor this: