如果我没有callback函数,Mongoose不会更新我的文档

这是我的模特:

var UserSchema = new Schema({ username: { type: String, unique: true, index: true }, url: { type: String }, name: { type: String }, github_id: { type: Number }, avatar_url: { type: String }, location: { type: String }, email: { type: String }, blog: { type: String }, public_repos: { type: Number }, public_gists: { type: Number }, last_github_sync: { type: Date }, created_at: { type: Date, default: Date.now } }); 

我尝试用findOneAndUpdate函数更新我的文档:

不起作用:

 User.findOneAndUpdate({ github_id: 1 }, { last_github_sync: new Date() }, {}); 

不起作用:

 User.findOneAndUpdate({ github_id: 1 }, { last_github_sync: new Date() }); 

作品:

 User.findOneAndUpdate({ github_id: 1 }, { last_github_sync: new Date() }, {}, function (err, numberAffected, raw) { }); 

我的意思是我应该绑定callback函数来使更新操作工作,但我不需要callback函数,我的代码有什么问题?

请参阅findOneAndUpdate 文档中的示例:

 A.findOneAndUpdate(conditions, update, options, callback) // executes A.findOneAndUpdate(conditions, update, options) // returns Query A.findOneAndUpdate(conditions, update, callback) // executes A.findOneAndUpdate(conditions, update) // returns Query A.findOneAndUpdate() // returns Query 

如果不提供callback,则返回一个Query对象,必须调用exec()才能执行更新。