push new value to mongodb inner array - mongodb/php
- by Rizky Ramadhan
hi
i have this document in mongo:
{
"_id": ObjectId("4d0b9c7a8b012fe287547157"),
"done_by": ["1"]
}
and i want to add another value to "done_by" field, so my expected document will be::
{
"_id": ObjectId("4d0b9c7a8b012fe287547157"),
"done_by": ["1","2","3"]
}
i try this:
$conn = new Mongo();
$q = $conn->server->gameQueue;
$id = new MongoId("4d0b9c7a8b012fe287547157");
$q->update(array("_id"=>$id),array('$push' => array("done_by","2")));
but nothing happens, anyone know how to do this?