You are browsing documentation for a version that is no longer maintained.
MongoDB supports a "find, modify, and return" command. This command can be used to atomically modify a document (at most one) and return it. Note that, by default, the document returned will not include the modifications made on the update.
Doctrine fully integrates the find and modify functionality to the query builder object so you can easily run these types of queries!
For example you can update a job and return it:
If you want to update a job and return the new document you can
Here is an example where we return the new updated job document:
1 'Job') // Find the job ->findAndUpdate() ->returnNew() ->field('in_progress')->equals(false) ->sort('priority', 'desc') // Update found job ->field('started')->set(new \MongoDate()) ->field('in_progress')->set(true) ->getQuery() ->execute();$job = $dm->createQueryBuilder( 2 3 4 5 6 7 8 9 10 11 12 13
$job will be a managed
Job instance with the
in_progress fields updated.
You can also remove a document and return it:
You can read more about the find and modify functionality on the MongoDB website.
If you don't need to return the document, you can use just run a normal update which can affect multiple documents, as well.