I have a typical schema and model:
var mongoose = require('mongoose');
var userSchema = new mongoose.Schema({
email: String,
password: String,
profile: {
name: String,
surname: String,
photo: String
},
stats: {
lastLogin: { type: Date, default: Date.now },
loginCount: Number,
lastIP: String
},
source: String,
deleted: Boolean,
dateCreated: { type: Date, default: Date.now }
});
mongoose.model('User', userSchema);
When I perform this update, it only works if I define the callback, else it simply executes but no value is changed in the database:
User.update({email:'foo@bar.com'}, {$inc: {'stats.loginCount': 1}});
This works:
User.update({email:'foo@bar.com'}, {$inc: {'stats.loginCount': 1}}, function() {});
Is this a bug? I don't see in the documentation if the callback is required but it's strange to require this… I think i'm missing something here.
Notes: I'm matching by email for testing proposes, I'm using mongoose v3.5.4 in NodeJS v0.8.17 with a simple Express v3.0.6 setup.
Thanks in advance.