I wanted to change a nested array value without first loading an entire MongoDB document in Lithium, but the documentation wasn’t clear. One of the developers on the #li3 IRC channel pointed me in the right direction.
Since the “atomic” option is defaulted to true, the $set is implied. The following example is with a model called “Lesson”:
$conditions = array('_id' => $_id); //conditions for document(s) to change $data = array(('page_list.123.title') => $title); //nested value I want to change Lesson::update($data,$conditions);
I hope that points you in the right direction. It’s like the native MongoCollection::update but with the first two parameters switched. You can also include a third parameter for options. Soon the update method will be patched to allow for MongoDB upserts.