yiisoft/yii2 — pull request #2613 by mongosoft (2014-03-04 09:46:25+00:00)
Title: add findAndModify() method to the Collection class

The findAndModify command atomically modifies and returns a single document. By default, the returned document does not include the modifications made on the update. To return the document with the modifications made on the update, use the new option.

This is very useful function. Example usage:

```php
/** @var \yii\mongodb\ActiveRecord $this */

$this->getCollection()->findAndModify->(
['_id' => $this->_id],
['$inc' => ['inc' => 1]],
['inc' => true, '_id' => false],
['new' => true]
);
```