You are browsing a version that is no longer maintained.
Doctrine MongoDB ODM implements several different strategies for persisting changes to mapped fields. These strategies apply to the following mapping types:
For collections, Doctrine tracks changes via the PersistentCollection class. The
strategies described on this page are implemented by the CollectionPersister
increment strategy cannot be used for collections.
increment strategy does not apply to collections but can be used for
float fields. When using the
increment strategy, the field
value will be updated using the $inc operator.
addToSet strategy uses MongoDB's $addToSet operator to insert
elements into the array. This strategy is useful for ensuring that duplicate
values will not be inserted into the collection. Like the pushAll strategy,
elements are inserted in a separate query after removing deleted elements.
set strategy uses MongoDB's $set operator to update the entire
collection with a single update query.
Doctrine's Collection interface is modeled after PHP's associative arrays,
so they cannot always be represented as a BSON array. If the collection's
keys are not sequential integers starting with zero, the
setArray strategy uses MongoDB's $set operator, just like the
strategy, but will first numerically reindex the collection to ensure that it is
stored as a BSON array.
pushAll strategy uses MongoDB's $push operator in combination with
$each to insert elements into the array. MongoDB does not allow elements to
be added and removed from an array in a single operation, so this strategy
relies on multiple update queries to remove and insert elements (in that order).
atomicSet strategy uses MongoDB's $set operator to update the entire
collection with a single update query. Unlike with
set strategy there will
be only one query for updating both parent document and collection itself. This
strategy can be especially useful when dealing with high concurrency and
atomicSetArray strategy works exactly like
atomicSet strategy, but
will first numerically reindex the collection to ensure that it is stored as a