$unset is empty. You must specify a field like so: {$unset: {: …}}

后端 未结 1 673
南笙
南笙 2020-12-19 02:18

mongodb version 3.0.1
mongoose version 4.0.3

I\'m trying to do this:

groupsModel.updateQ({_id:group._id},{
    $unset:{\"moderators\":\"\"},
             


        
相关标签:
1条回答
  • 2020-12-19 02:39

    I wasn't able to reproduce that error message, but as you've seen, Mongoose will only update fields defined in the schema. However, you can override that default behavior by including the strict: false option:

    groupsModel.update(
        {_id: group._id},
        {$unset: {"moderators": ""}, $set:{"admins": newAdmins}},
        {strict: false}
    )
    
    0 讨论(0)
提交回复
热议问题