Package dev.morphia.query
Interface UpdateOperations<T>
-
- Type Parameters:
T- The Java type used in the updates
- All Known Implementing Classes:
UpdateOpsImpl
public interface UpdateOperations<T>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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description UpdateOperations<T>add(java.lang.String field, java.lang.Object value)Deprecated.useaddToSet(String, Object)insteadUpdateOperations<T>add(java.lang.String field, java.lang.Object value, boolean addDups)Deprecated.usepush(String, Object)if addDups is true oraddToSet(String, Object)insteadUpdateOperations<T>addAll(java.lang.String field, java.util.List<?> values, boolean addDups)Deprecated.usepush(String, List)if addDups is true oraddToSet(String, List)UpdateOperations<T>addToSet(java.lang.String field, java.lang.Iterable<?> values)adds the values to an array field if they doesn't already exist in the arrayUpdateOperations<T>addToSet(java.lang.String field, java.lang.Object value)adds the value to an array field if it doesn't already exist in the arrayUpdateOperations<T>addToSet(java.lang.String field, java.util.List<?> values)adds the values to an array field if they doesn't already exist in the arrayUpdateOperations<T>dec(java.lang.String field)Decrements the numeric field by 1UpdateOperations<T>dec(java.lang.String field, java.lang.Number value)Decrements the numeric field by value (must be a positive Double, Float, Long, or Integer).UpdateOperations<T>disableValidation()Turns off validation (for all calls made after)UpdateOperations<T>enableValidation()Turns on validation (for all calls made after); by default validation is onUpdateOperations<T>inc(java.lang.String field)Increments the numeric field by 1UpdateOperations<T>inc(java.lang.String field, java.lang.Number value)increments the numeric field by value (negatives are allowed)booleanisIsolated()Deprecated.this functionality is deprecated in mongodb 3.6 and has been removed from 4.0UpdateOperations<T>isolated()Deprecated.this functionality is deprecated in mongodb 3.6 and has been removed from 4.0UpdateOperations<T>max(java.lang.String field, java.lang.Number value)Sets the numeric field to value if it is greater than the current value.UpdateOperations<T>min(java.lang.String field, java.lang.Number value)sets the numeric field to value if it is less than the current value.UpdateOperations<T>push(java.lang.String field, java.lang.Object value)Adds new values to an array field.UpdateOperations<T>push(java.lang.String field, java.lang.Object value, PushOptions options)Adds new values to an array field at the given positionUpdateOperations<T>push(java.lang.String field, java.util.List<?> values)Adds new values to an array field.UpdateOperations<T>push(java.lang.String field, java.util.List<?> values, PushOptions options)Adds new values to an array field at the given positionUpdateOperations<T>removeAll(java.lang.String field, java.lang.Object value)removes the value from the array fieldUpdateOperations<T>removeAll(java.lang.String field, java.util.List<?> values)removes the values from the array fieldUpdateOperations<T>removeFirst(java.lang.String field)removes the first value from the arrayUpdateOperations<T>removeLast(java.lang.String field)removes the last value from the arrayUpdateOperations<T>set(java.lang.String field, java.lang.Object value)sets the field valueUpdateOperations<T>setOnInsert(java.lang.String field, java.lang.Object value)sets the field on insert.UpdateOperations<T>unset(java.lang.String field)removes the field
-
-
-
Method Detail
-
add
@Deprecated UpdateOperations<T> add(java.lang.String field, java.lang.Object value)
Deprecated.useaddToSet(String, Object)insteadadds the value to an array field- Parameters:
field- the field to updatevalue- the value to add- Returns:
- this
- MongoDB documentation
- reference/operator/update/addToSet/ $addToSet
-
add
@Deprecated UpdateOperations<T> add(java.lang.String field, java.lang.Object value, boolean addDups)
Deprecated.usepush(String, Object)if addDups is true oraddToSet(String, Object)insteadadds the value to an array field- Parameters:
field- the field to updatevalue- the value to addaddDups- if true, the value will be added even if it already exists in the array ($push)- Returns:
- this
- MongoDB documentation
- reference/operator/update/addToSet/ $addToSet
- reference/operator/update/push/ $push
-
addAll
@Deprecated UpdateOperations<T> addAll(java.lang.String field, java.util.List<?> values, boolean addDups)
Deprecated.usepush(String, List)if addDups is true oraddToSet(String, List)adds the values to an array field- Parameters:
field- the field to updatevalues- the values to addaddDups- if true, the values will be added even if they already exists in the array ($push)- Returns:
- this
- MongoDB documentation
- reference/operator/update/addToSet/ $addToSet
- reference/operator/update/push/ $push
-
addToSet
UpdateOperations<T> addToSet(java.lang.String field, java.lang.Object value)
adds the value to an array field if it doesn't already exist in the array- Parameters:
field- the field to updatevalue- the value to add- Returns:
- this
- MongoDB documentation
- reference/operator/update/addToSet/ $addToSet
-
addToSet
UpdateOperations<T> addToSet(java.lang.String field, java.util.List<?> values)
adds the values to an array field if they doesn't already exist in the array- Parameters:
field- the field to updatevalues- the values to add- Returns:
- this
- MongoDB documentation
- reference/operator/update/addToSet/ $addToSet
-
addToSet
UpdateOperations<T> addToSet(java.lang.String field, java.lang.Iterable<?> values)
adds the values to an array field if they doesn't already exist in the array- Parameters:
field- the field to updatevalues- the values to add- Returns:
- this
- MongoDB documentation
- reference/operator/update/addToSet/ $addToSet
-
dec
UpdateOperations<T> dec(java.lang.String field)
Decrements the numeric field by 1- Parameters:
field- the field to update- Returns:
- this
- MongoDB documentation
- reference/operator/update/inc/ $inc
-
dec
UpdateOperations<T> dec(java.lang.String field, java.lang.Number value)
Decrements the numeric field by value (must be a positive Double, Float, Long, or Integer).- Parameters:
field- the field to updatevalue- the value to decrement by- Returns:
- this
- Throws:
java.lang.IllegalArgumentException- of the value is not an instance of Double, Float,Long, or Integer- MongoDB documentation
- reference/operator/update/inc/ $inc
-
disableValidation
UpdateOperations<T> disableValidation()
Turns off validation (for all calls made after)- Returns:
- this
-
enableValidation
UpdateOperations<T> enableValidation()
Turns on validation (for all calls made after); by default validation is on- Returns:
- this
-
inc
UpdateOperations<T> inc(java.lang.String field)
Increments the numeric field by 1- Parameters:
field- the field to update- Returns:
- this
- MongoDB documentation
- reference/operator/update/inc/ $inc
-
inc
UpdateOperations<T> inc(java.lang.String field, java.lang.Number value)
increments the numeric field by value (negatives are allowed)- Parameters:
field- the field to updatevalue- the value to increment by- Returns:
- this
- MongoDB documentation
- reference/operator/update/inc/ $inc
-
isolated
@Deprecated UpdateOperations<T> isolated()
Deprecated.this functionality is deprecated in mongodb 3.6 and has been removed from 4.0Enables isolation (so this update happens in one shot, without yielding)- Returns:
- this
- MongoDB documentation
- reference/operator/update/isolated/ $isolated
-
isIsolated
@Deprecated boolean isIsolated()
Deprecated.this functionality is deprecated in mongodb 3.6 and has been removed from 4.0- Returns:
- true if this update is to be run in isolation
- Since:
- 1.3
- MongoDB documentation
- reference/operator/update/isolated/ $isolated
-
max
UpdateOperations<T> max(java.lang.String field, java.lang.Number value)
Sets the numeric field to value if it is greater than the current value.- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
- MongoDB documentation
- reference/operator/update/max/ $max
-
min
UpdateOperations<T> min(java.lang.String field, java.lang.Number value)
sets the numeric field to value if it is less than the current value.- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
- MongoDB documentation
- reference/operator/update/min/ $min
-
push
UpdateOperations<T> push(java.lang.String field, java.lang.Object value)
Adds new values to an array field.- Parameters:
field- the field to updatedvalue- the value to add- Returns:
- this
- MongoDB documentation
- reference/operator/update/push/ $push
-
push
UpdateOperations<T> push(java.lang.String field, java.lang.Object value, PushOptions options)
Adds new values to an array field at the given position- Parameters:
field- the field to updatedvalue- the value to addoptions- the options to apply to the push- Returns:
- this
- MongoDB documentation
- reference/operator/update/push/ $push
-
push
UpdateOperations<T> push(java.lang.String field, java.util.List<?> values)
Adds new values to an array field.- Parameters:
field- the field to updatedvalues- the values to add- Returns:
- this
- MongoDB documentation
- reference/operator/update/push/ $push
-
push
UpdateOperations<T> push(java.lang.String field, java.util.List<?> values, PushOptions options)
Adds new values to an array field at the given position- Parameters:
field- the field to updatedvalues- the values to addoptions- the options to apply to the push- Returns:
- this
- MongoDB documentation
- reference/operator/update/push/ $push
-
removeAll
UpdateOperations<T> removeAll(java.lang.String field, java.lang.Object value)
removes the value from the array field- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
- MongoDB documentation
- reference/operator/update/pull/ $pull
-
removeAll
UpdateOperations<T> removeAll(java.lang.String field, java.util.List<?> values)
removes the values from the array field- Parameters:
field- the field to updatevalues- the values to use- Returns:
- this
- MongoDB documentation
- reference/operator/update/pullAll/ $pullAll
-
removeFirst
UpdateOperations<T> removeFirst(java.lang.String field)
removes the first value from the array- Parameters:
field- the field to update- Returns:
- this
- MongoDB documentation
- reference/operator/update/pop/ $pop
-
removeLast
UpdateOperations<T> removeLast(java.lang.String field)
removes the last value from the array- Parameters:
field- the field to update- Returns:
- this
- MongoDB documentation
- reference/operator/update/pop/ $pop
-
set
UpdateOperations<T> set(java.lang.String field, java.lang.Object value)
sets the field value- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
- MongoDB documentation
- reference/operator/update/set/ $set
-
setOnInsert
UpdateOperations<T> setOnInsert(java.lang.String field, java.lang.Object value)
sets the field on insert.- Parameters:
field- the field to updatevalue- the value to use- Returns:
- this
- MongoDB documentation
- reference/operator/update/setOnInsert/ $setOnInsert
-
unset
UpdateOperations<T> unset(java.lang.String field)
removes the field- Parameters:
field- the field to update- Returns:
- this
- MongoDB documentation
- reference/operator/update/unset/ $unset
-
-