Mongoose doesn't update my document if I have no callback function

后端 未结 1 1988
闹比i
闹比i 2021-01-19 22:15

This is my model:

var UserSchema = new Schema({
    username: { type: String, unique: true, index: true },
    url: { type: String },
    name: { type: Strin         


        
相关标签:
1条回答
  • 2021-01-19 22:41

    See the examples in the findOneAndUpdate documentation:

    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
    

    If you don't provide a callback, it returns a Query object that you must call exec() on to execute the update.

    0 讨论(0)
提交回复
热议问题