【问题标题】:What is the difference between the remove() method and the update() method while remove a field form the documents?从文档中删除字段时,remove() 方法和 update() 方法有什么区别?
【发布时间】:2021-11-27 05:44:10
【问题描述】:

我想从文档中删除一个字段,所以请告诉我我必须使用带有 $unset 运算符的 remove() 方法或 update() 方法。

【问题讨论】:

    标签: mongodb mongoose mongodb-query aggregate-functions compass


    【解决方案1】:

    您需要带有$unset 运算符的update() 方法。

    remove()是删除文档。

    【讨论】:

    • 表示update()用于删除文档,update()方法用于删除或移除字段
    • remove() = 删除文档。 update() = 设置文档字段。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-15
    • 2016-08-11
    • 2022-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-09
    相关资源
    最近更新 更多