Mongoose instance .save() not working when embedded array object changed

前端 未结 3 1371
天命终不由人
天命终不由人 2021-01-17 23:47

I am using Mongoose npm module to manage mongodb. This is schema of mongodb collection what I am going to update.

var UserSchema = new Schema({
    username:         


        
3条回答
  •  灰色年华
    2021-01-18 00:30

    If you just want to update cards based on cardIndex:

    User.update({_id: userID}, {'$set': {
        'cards.cardIndex': cardInfo
    }}, function(err) {
       //code
    }
    

提交回复
热议问题