Q:

mongodb: Trying to push a value in mongodb

I'm trying to $push a value in an array inside mongodb. This is the query:
db.user.update(
{ "_id": 5ac34a3c23f1b0343c155782 },
{ $push: { "courseId":5acd192a3ff62a287452891f}});

The first id, after _id is coming from a user model with this parameter, "_id" : ObjectId("5acb75a9e773ed2c10d5caa8").
The second id, after courseId is coming from this parameter "_id" : ObjectId("5acd192a3ff62a287452891f").
Desired user model should look like:

"_id" : ObjectId("5ac34a3c23f1b0343c155782"),
        "tokens" : [ ],
        "courseId" : [
                "5ac37f5cd494e905b86c2433",
                "<new id>"
        ],

Where am I going wrong?

A:

db.user.update({ "_id": 5ac34a3c23f1b0343c155782 }, { $push: { "courseId":5acd192a3ff62a287452891f}})

You may need to use the "_id": ObjectId("5ac34a3c23f1b0343c155782") instead of just alphanumeric

