How to use MongoDB update operators
Clone this wiki locally
CakeMongo always uses $set operator for update.
If you don't want to use $set operator, you can chose any one as follw.
Set TRUE in Model::mongoNoSetOperator property.
Set a mongodb operator in a key of save data as follow. Don't use Model::mongoSchema property,CakePHP delete '$inc' data in Model::Save().
<? Model->save(array('_id' => $id, '$inc' => array('count' => 1)));
- Set a Mongo operator in Model::mongoNoSetOperator property.
<? Model->mongoNoSetOperator = '$inc'; Model->save(array('_id' => $id, array('count' => 1)));
If you want to know examples, please check test code "testUpdate()" and " testUpdateWithout_mongoSchemaProperty()" https://github.com/ichikaway/cakephp-mongodb/blob/master/tests/cases/datasources/mongodb_source.test.php