package org.mongodb.morphia.query;


import java.util.List;


A nicer interface to the update operations in monogodb. All these operations happen at the server and can cause the server and client version of the Entity to be different

Type parameters:
  • <T> – The Java type used in the updates
/** * <p> A nicer interface to the update operations in monogodb. All these operations happen at the server and can cause the server and * client * version of the Entity to be different </p> * * @param <T> The Java type used in the updates */
public interface UpdateOperations<T> {
adds the value to an array field
Params:
  • field – the field to update
  • value – the value to add
Returns:this
@mongodb.driver.manualreference/operator/update/addToSet/ $addToSet
Deprecated:use addToSet(String, Object) instead
/** * adds the value to an array field * * @param field the field to update * @param value the value to add * @return this * @mongodb.driver.manual reference/operator/update/addToSet/ $addToSet * @deprecated use {@link #addToSet(String, Object)} instead */
@Deprecated UpdateOperations<T> add(String field, Object value);
adds the value to an array field
Params:
  • field – the field to update
  • value – the value to add
  • addDups – if true, the value will be added even if it already exists in the array ($push)
Returns:this
@mongodb.driver.manualreference/operator/update/addToSet/ $addToSet
@mongodb.driver.manualreference/operator/update/push/ $push
Deprecated:use push(String, Object) if addDups is false or addToSet(String, Object) instead
/** * adds the value to an array field * * @param field the field to update * @param value the value to add * @param addDups if true, the value will be added even if it already exists in the array ($push) * @return this * @mongodb.driver.manual reference/operator/update/addToSet/ $addToSet * @mongodb.driver.manual reference/operator/update/push/ $push * @deprecated use {@link #push(String, Object)} if addDups is false or {@link #addToSet(String, Object)} instead */
@Deprecated UpdateOperations<T> add(String field, Object value, boolean addDups);
adds the values to an array field
Params:
  • field – the field to update
  • values – the values to add
  • addDups – if true, the values will be added even if they already exists in the array ($push)
Returns:this
@mongodb.driver.manualreference/operator/update/addToSet/ $addToSet
@mongodb.driver.manualreference/operator/update/push/ $push
Deprecated:use push(String, List) if addDups is false or addToSet(String, List)
/** * adds the values to an array field * * @param field the field to update * @param values the values to add * @param addDups if true, the values will be added even if they already exists in the array ($push) * @return this * @mongodb.driver.manual reference/operator/update/addToSet/ $addToSet * @mongodb.driver.manual reference/operator/update/push/ $push * @deprecated use {@link #push(String, List)} if addDups is false or {@link #addToSet(String, List)} */
@Deprecated UpdateOperations<T> addAll(String field, List<?> values, boolean addDups);
adds the value to an array field if it doesn't already exist in the array
Params:
  • field – the field to update
  • value – the value to add
Returns:this
@mongodb.driver.manualreference/operator/update/addToSet/ $addToSet
/** * adds the value to an array field if it doesn't already exist in the array * * @param field the field to update * @param value the value to add * @return this * @mongodb.driver.manual reference/operator/update/addToSet/ $addToSet */
UpdateOperations<T> addToSet(String field, Object value);
adds the values to an array field if they doesn't already exist in the array
Params:
  • field – the field to update
  • values – the values to add
Returns:this
@mongodb.driver.manualreference/operator/update/addToSet/ $addToSet
/** * adds the values to an array field if they doesn't already exist in the array * * @param field the field to update * @param values the values to add * @return this * @mongodb.driver.manual reference/operator/update/addToSet/ $addToSet */
UpdateOperations<T> addToSet(String field, List<?> values);
Decrements the numeric field by 1
Params:
  • field – the field to update
Returns:this
@mongodb.driver.manualreference/operator/update/inc/ $inc
/** * Decrements the numeric field by 1 * * @param field the field to update * @return this * @mongodb.driver.manual reference/operator/update/inc/ $inc */
UpdateOperations<T> dec(String field);
Decrements the numeric field by value (must be a positive Double, Float, Long, or Integer).
Params:
  • field – the field to update
  • value – the value to decrement by
Throws:
Returns:this
@mongodb.driver.manualreference/operator/update/inc/ $inc
/** * Decrements the numeric field by value (must be a positive Double, * Float, Long, or Integer). * * @param field the field to update * @param value the value to decrement by * @throws IllegalArgumentException of the value is not an instance of * Double, Float,Long, or Integer * @return this * @mongodb.driver.manual reference/operator/update/inc/ $inc */
UpdateOperations<T> dec(String field, Number value);
Turns off validation (for all calls made after)
Returns:this
/** * Turns off validation (for all calls made after) * * @return this */
UpdateOperations<T> disableValidation();
Turns on validation (for all calls made after); by default validation is on
Returns:this
/** * Turns on validation (for all calls made after); by default validation is on * * @return this */
UpdateOperations<T> enableValidation();
Increments the numeric field by 1
Params:
  • field – the field to update
Returns:this
@mongodb.driver.manualreference/operator/update/inc/ $inc
/** * Increments the numeric field by 1 * * @param field the field to update * @return this * @mongodb.driver.manual reference/operator/update/inc/ $inc */
UpdateOperations<T> inc(String field);
increments the numeric field by value (negatives are allowed)
Params:
  • field – the field to update
  • value – the value to increment by
Returns:this
@mongodb.driver.manualreference/operator/update/inc/ $inc
/** * increments the numeric field by value (negatives are allowed) * * @param field the field to update * @param value the value to increment by * @return this * @mongodb.driver.manual reference/operator/update/inc/ $inc */
UpdateOperations<T> inc(String field, Number value);
Enables isolation (so this update happens in one shot, without yielding)
Returns:this
@mongodb.driver.manualreference/operator/update/isolated/ $isolated
/** * Enables isolation (so this update happens in one shot, without yielding) * * @return this * @mongodb.driver.manual reference/operator/update/isolated/ $isolated */
UpdateOperations<T> isolated();
Returns:true if this update is to be run in isolation
@mongodb.driver.manualreference/operator/update/isolated/ $isolated
Since:1.3
/** * @return true if this update is to be run in isolation * * @mongodb.driver.manual reference/operator/update/isolated/ $isolated * @since 1.3 */
boolean isIsolated();
Sets the numeric field to value if it is greater than the current value.
Params:
  • field – the field to update
  • value – the value to use
Returns:this
@mongodb.driver.manualreference/operator/update/max/ $max
/** * Sets the numeric field to value if it is greater than the current value. * * @param field the field to update * @param value the value to use * @return this * @mongodb.driver.manual reference/operator/update/max/ $max */
UpdateOperations<T> max(String field, Number value);
sets the numeric field to value if it is less than the current value.
Params:
  • field – the field to update
  • value – the value to use
Returns:this
@mongodb.driver.manualreference/operator/update/min/ $min
/** * sets the numeric field to value if it is less than the current value. * * @param field the field to update * @param value the value to use * @return this * @mongodb.driver.manual reference/operator/update/min/ $min */
UpdateOperations<T> min(String field, Number value);
Adds new values to an array field.
Params:
  • field – the field to updated
  • value – the value to add
Returns:this
@mongodb.driver.manualreference/operator/update/push/ $push
/** * Adds new values to an array field. * * @param field the field to updated * @param value the value to add * @return this * @mongodb.driver.manual reference/operator/update/push/ $push */
UpdateOperations<T> push(String field, Object value);
Adds new values to an array field at the given position
Params:
  • field – the field to updated
  • value – the value to add
  • options – the options to apply to the push
Returns:this
@mongodb.driver.manualreference/operator/update/push/ $push
/** * Adds new values to an array field at the given position * * @param field the field to updated * @param value the value to add * @param options the options to apply to the push * @return this * @mongodb.driver.manual reference/operator/update/push/ $push */
UpdateOperations<T> push(String field, Object value, final PushOptions options);
Adds new values to an array field.
Params:
  • field – the field to updated
  • values – the values to add
Returns:this
@mongodb.driver.manualreference/operator/update/push/ $push
/** * Adds new values to an array field. * * @param field the field to updated * @param values the values to add * @return this * @mongodb.driver.manual reference/operator/update/push/ $push */
UpdateOperations<T> push(String field, List<?> values);
Adds new values to an array field at the given position
Params:
  • field – the field to updated
  • values – the values to add
  • options – the options to apply to the push
Returns:this
@mongodb.driver.manualreference/operator/update/push/ $push
/** * Adds new values to an array field at the given position * * @param field the field to updated * @param values the values to add * @param options the options to apply to the push * @return this * @mongodb.driver.manual reference/operator/update/push/ $push */
UpdateOperations<T> push(String field, List<?> values, PushOptions options);
removes the value from the array field
Params:
  • field – the field to update
  • value – the value to use
Returns:this
@mongodb.driver.manualreference/operator/update/pull/ $pull
/** * removes the value from the array field * * @param field the field to update * @param value the value to use * @return this * @mongodb.driver.manual reference/operator/update/pull/ $pull */
UpdateOperations<T> removeAll(String field, Object value);
removes the values from the array field
Params:
  • field – the field to update
  • values – the values to use
Returns:this
@mongodb.driver.manualreference/operator/update/pullAll/ $pullAll
/** * removes the values from the array field * * @param field the field to update * @param values the values to use * @return this * @mongodb.driver.manual reference/operator/update/pullAll/ $pullAll */
UpdateOperations<T> removeAll(String field, List<?> values);
removes the first value from the array
Params:
  • field – the field to update
Returns:this
@mongodb.driver.manualreference/operator/update/pop/ $pop
/** * removes the first value from the array * * @param field the field to update * @return this * @mongodb.driver.manual reference/operator/update/pop/ $pop */
UpdateOperations<T> removeFirst(String field);
removes the last value from the array
Params:
  • field – the field to update
Returns:this
@mongodb.driver.manualreference/operator/update/pop/ $pop
/** * removes the last value from the array * * @param field the field to update * @return this * @mongodb.driver.manual reference/operator/update/pop/ $pop */
UpdateOperations<T> removeLast(String field);
sets the field value
Params:
  • field – the field to update
  • value – the value to use
Returns:this
@mongodb.driver.manualreference/operator/update/set/ $set
/** * sets the field value * * @param field the field to update * @param value the value to use * @return this * @mongodb.driver.manual reference/operator/update/set/ $set */
UpdateOperations<T> set(String field, Object value);
sets the field on insert.
Params:
  • field – the field to update
  • value – the value to use
Returns:this
@mongodb.driver.manualreference/operator/update/setOnInsert/ $setOnInsert
/** * sets the field on insert. * * @param field the field to update * @param value the value to use * @return this * @mongodb.driver.manual reference/operator/update/setOnInsert/ $setOnInsert */
UpdateOperations<T> setOnInsert(String field, Object value);
removes the field
Params:
  • field – the field to update
Returns:this
@mongodb.driver.manualreference/operator/update/unset/ $unset
/** * removes the field * * @param field the field to update * @return this * @mongodb.driver.manual reference/operator/update/unset/ $unset */
UpdateOperations<T> unset(String field); }