查询调用数组而不是类型"对象"



我不知道为什么下面的查询已经停止工作。基本上,我们有listenerlocation和pastlistenerlocation,似乎我们的pastlistenerlocation不想更新。

BSON field 'update.updates.u' is the wrong type 'array', expected type 'object'",

我正在运行的查询是:

db.getCollection("pastlistenerslocation").updateMany(
{ "location.coordinates": { $exists: true } },
[{
$set: {
"location.coordinates": [
{ 
$toDouble: {
$arrayElemAt: ["$location.coordinates", 0]
}
},
{ 
$toDouble: {
$arrayElemAt: ["$location.coordinates", 1]
}
}
]
}
}]
)

我的数据看起来像

{ 
"_id" : ObjectId("60b5f1fe0948ad2d50428b48"), 
"location" : {
"coordinates" : [
"115.88027251449634", 
"-31.925607553334974"
]
}, 
"timestamp" : ISODate("2021-06-01T08:38:21.212+0000")
}

我使用Mongodb 4.0.3版本。

updateMany的第二个参数是一个数组:MongoDB期望它是一个对象。

最新更新