I'm not sure why the following query has stopped working. Basically we have listener location and pastlistenerlocation and it seems our pastlistenerlocation does not want to update.
BSON field 'update.updates.u' is the wrong type 'array', expected type 'object'",
The query I am running is:
db.getCollection("pastlistenerslocation").updateMany(
{ "location.coordinates": { $exists: true } },
[{
$set: {
"location.coordinates": [
{
$toDouble: {
$arrayElemAt: ["$location.coordinates", 0]
}
},
{
$toDouble: {
$arrayElemAt: ["$location.coordinates", 1]
}
}
]
}
}]
)
My data looks like
{
"_id" : ObjectId("60b5f1fe0948ad2d50428b48"),
"location" : {
"coordinates" : [
"115.88027251449634",
"-31.925607553334974"
]
},
"timestamp" : ISODate("2021-06-01T08:38:21.212+0000")
}
I am using Mongodb version 4.0.3.