I have these coordinates in the wrong order I need to reverse them for all collections:
{
_id: ObjectId("638f9866d9014fabfc47275e"),
address: '801 Pine St, Anchorage, AK',
name: 'Russian Jack Skatepark',
location: { type: 'Point', coordinates: [ 61.214855, -149.793563 ] }
}
>Solution :
You can use $reverseArray as follow:
db.collection.update({},
[
{
$set: {
"location.coordinates": {
$reverseArray: "$location.coordinates"
}
}
}
])