Q:

How do I push nested array values to a mongodb document?

If I have a document in mongodb with this structure:
{
    "_id": "user1",
    "loc": [
        {
            "lon": 51.12076493195686,
            "lat": -113.98040771484375
        },
        {
            "lon": 51.10682735591432,
            "lat": -114.11773681640625
        }
    ]
}

How would I be able to push a new array containing lon and lat within the loc list?
The structure I am trying to use is this: db.collection('location').update({_id:'user1'},{'$push': {"lat": "-107.10400390625", "lon": "33.32343323432" }})
This obviously does not work because the lat and lon are nested within loc.

A:

db.collection('location').update({_id:'user1'},{'$push': { "loc": {"lat": "-107.10400390625", "lon": "33.32343323432" }}})

