gpt4 book ai didi

mongodb - 更新符合条件的所有字段值

转载 作者:可可西里 更新时间:2023-11-01 10:00:59 31 4
gpt4 key购买 nike

我正在尝试更改值低于 0 的作者的值我用这个但没有结果:

db.posts.update({author:{$lt:0}},{$set:{author:582127753}})

有什么想法吗?

最佳答案

From the Mongo docs -

By default, the update() method updates a single document that matches its selection criteria. Call the method with the multi option set to true to update multiple documents.

所以你应该像这样运行你的查询:

db.posts.update(
{author:{$lt:0}},
{$set:{author:582127753}},
{ multi: true }
)

关于mongodb - 更新符合条件的所有字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20601611/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com