gpt4 book ai didi

mongodb - 运行 updateOne 时出现错误 : the update operation document must contain atomic operators,

转载 作者:IT老高 更新时间:2023-10-28 11:02:09 24 4
gpt4 key购买 nike

在我的收藏中,只有一个文档。

> db.c20160712.find()
{ "_id" : ObjectId("57ab909791c3b3a393e9e277"), "Dimension_id" : 2, "Attribute" : "good", "Hour" : "20160712_06", "Frequency_count" : 100

我想运行 updateOne 将文档替换为另一个文档。但是为什么会出现Error: the update operation document must contain atomic operators

> db.c20160712.updateOne( { "Attribute" : "good"}, {"Type" : "DVD", "Title" : "Matrix, The", "Released" : 1999, "Genre" : "Action"}, { upsert: true} )
2016-08-10T16:37:57.089-0400 E QUERY [thread1] Error: the update operation document must contain atomic operators :
DBCollection.prototype.updateOne@src/mongo/shell/crud_api.js:493:1
@(shell):1:1

上述命令中的第二个和第三个参数来自The Definitive Guide to MongoDB: A complete guide to dealing with Big Data ...By Eelco Plugge, David Hows, Peter Membrey, Tim Hawkins 中的一个示例。

我的 MongoDB 是 3.2。

最佳答案

第二个参数的语法错误。请查看the docs .应该是:

db.c20160712.updateOne(
{ "Attribute" : "good" },
{ $set: {"Type" : "DVD", "Title" : "Matrix, The", "Released" : 1999, "Genre" : "Action" } },
{ upsert: true }
);

关于mongodb - 运行 updateOne 时出现错误 : the update operation document must contain atomic operators,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38883285/

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