我有这些坐标在错误的顺序,我需要颠倒它们为所有集合:
{
_id: ObjectId("638f9866d9014fabfc47275e"),
address: '801 Pine St, Anchorage, AK',
name: 'Russian Jack Skatepark',
location: { type: 'Point', coordinates: [ 61.214855, -149.793563 ] }
}
$reverseArray的用法如下:
db.collection.updateMany({},
[
{
$set: {
"location.coordinates": {
$reverseArray: "$location.coordinates"
}
}
}
])
Playgrouund