Using mongoose to add new field to existing document in mongodb through update method

后端 未结 3 1592
南笙
南笙 2021-02-20 07:45

I\'m trying to update a mongodb document with mongoose in node.js

When the field exists, the update works, but if the field does not exist, the update will not work.

3条回答
  •  旧时难觅i
    2021-02-20 08:38

    Going through this solution in Year 2019.

    Please note: collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead

提交回复
热议问题