Package dev.morphia.query
Interface Updates<Updater extends Updates>
-
- Type Parameters:
Updater
-
public interface Updates<Updater extends Updates>
Defines the update operations available
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description Updater
addToSet(String field, Iterable<?> values)
adds the values to an array field if they doesn't already exist in the arrayUpdater
addToSet(String field, Object value)
adds the value to an array field if it doesn't already exist in the arrayUpdater
addToSet(String field, List<?> values)
adds the values to an array field if they doesn't already exist in the arrayUpdater
dec(String field)
Decrements the numeric field by 1Updater
dec(String field, Number value)
Decrements the numeric field by value (must be a positive Double, Float, Long, or Integer).Updater
disableValidation()
Turns off validation (for all calls made after)Updater
enableValidation()
Turns on validation (for all calls made after); by default validation is onUpdater
inc(String field)
Increments the numeric field by 1Updater
inc(String field, Number value)
increments the numeric field by value (negatives are allowed)Updater
max(String field, Number value)
Sets the numeric field to value if it is greater than the current value.Updater
min(String field, Number value)
sets the numeric field to value if it is less than the current value.Updater
pull(String field, Object value)
removes the value from the array fieldUpdater
pullAll(String field, List<?> values)
removes the values from the array fieldUpdater
push(String field, Object value)
Adds new values to an array field.Updater
push(String field, Object value, PushOptions options)
Adds new values to an array field at the given positionUpdater
push(String field, List<?> values)
Adds new values to an array field.Updater
push(String field, List<?> values, PushOptions options)
Adds new values to an array field at the given positiondefault Updater
removeAll(String field, Object value)
Deprecated, for removal: This API element is subject to removal in a future version.usepull(String, Object)
insteaddefault Updater
removeAll(String field, List<?> values)
Deprecated, for removal: This API element is subject to removal in a future version.usepullAll(String, List)
insteadUpdater
removeFirst(String field)
removes the first value from the arrayUpdater
removeLast(String field)
removes the last value from the arrayUpdater
set(Object entity)
sets the entity value to completely replace the stored documentUpdater
set(String field, Object value)
sets the field valueUpdater
setOnInsert(String field, Object value)
sets the field on insert.Updater
unset(String field)
removes the field
-
-
-
Method Detail
-
addToSet
Updater addToSet(String field, 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
- $addToSet
-
addToSet
Updater addToSet(String field, 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
- $addToSet
-
addToSet
Updater addToSet(String field, 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
- $addToSet
-
dec
Updater dec(String field)
Decrements the numeric field by 1- Parameters:
field
- the field to update- Returns:
- this
- MongoDB documentation
- $inc
-
dec
Updater dec(String field, 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:
IllegalArgumentException
- of the value is not an instance of Double, Float,Long, or Integer- MongoDB documentation
- $inc
-
disableValidation
Updater disableValidation()
Turns off validation (for all calls made after)- Returns:
- this
-
enableValidation
Updater enableValidation()
Turns on validation (for all calls made after); by default validation is on- Returns:
- this
-
inc
Updater inc(String field)
Increments the numeric field by 1- Parameters:
field
- the field to update- Returns:
- this
- MongoDB documentation
- $inc
-
inc
Updater inc(String field, 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
- $inc
-
max
Updater max(String field, 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
- $max
-
min
Updater min(String field, 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
- $min
-
push
Updater push(String field, Object value)
Adds new values to an array field.- Parameters:
field
- the field to updatedvalue
- the value to add- Returns:
- this
- MongoDB documentation
- $push
-
push
Updater push(String field, 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
- $push
-
push
Updater push(String field, List<?> values)
Adds new values to an array field.- Parameters:
field
- the field to updatedvalues
- the values to add- Returns:
- this
- MongoDB documentation
- $push
-
push
Updater push(String field, 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
- $push
-
removeAll
@Deprecated(since="2.0", forRemoval=true) default Updater removeAll(String field, Object value)
Deprecated, for removal: This API element is subject to removal in a future version.usepull(String, Object)
insteadremoves the value from the array field- Parameters:
field
- the field to updatevalue
- the value to use- Returns:
- this
- MongoDB documentation
- $pull
-
pull
Updater pull(String field, Object value)
removes the value from the array field- Parameters:
field
- the field to updatevalue
- the value to use- Returns:
- this
- MongoDB documentation
- $pull
-
removeAll
@Deprecated(since="2.0", forRemoval=true) default Updater removeAll(String field, List<?> values)
Deprecated, for removal: This API element is subject to removal in a future version.usepullAll(String, List)
insteadremoves the values from the array field- Parameters:
field
- the field to updatevalues
- the values to use- Returns:
- this
- MongoDB documentation
- $pullAll
-
pullAll
Updater pullAll(String field, List<?> values)
removes the values from the array field- Parameters:
field
- the field to updatevalues
- the values to use- Returns:
- this
- MongoDB documentation
- $pullAll
-
removeFirst
Updater removeFirst(String field)
removes the first value from the array- Parameters:
field
- the field to update- Returns:
- this
- MongoDB documentation
- $pop
-
removeLast
Updater removeLast(String field)
removes the last value from the array- Parameters:
field
- the field to update- Returns:
- this
- MongoDB documentation
- $pop
-
set
Updater set(String field, Object value)
sets the field value- Parameters:
field
- the field to updatevalue
- the value to use- Returns:
- this
- MongoDB documentation
- $set
-
set
Updater set(Object entity)
sets the entity value to completely replace the stored document- Parameters:
entity
- the entity to store- Returns:
- this
- MongoDB documentation
- $set
-
setOnInsert
Updater setOnInsert(String field, Object value)
sets the field on insert.- Parameters:
field
- the field to updatevalue
- the value to use- Returns:
- this
- MongoDB documentation
- $setOnInsert
-
-