In the mongodb document I have, it is structured like so:
{
"_id": "user1",
"loc": [
{
"lon": 51.12076493195686,
"lat": -113.98040771484375
},
{
"lon": 51.10682735591432,
"lat": -114.11773681640625
}
]
}
I am wondering how to add a new array of lon and lat within the loc list?
The code snippet I tried was:
db.collection('location').update({_id:'user1'},{'$push': {"lat": "-107.10400390625", "lon": "33.32343323432" }})
However, this approach doesn't work because lat and lon are actually nested within loc.