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 UpdateraddToSet(String field, Iterable<?> values)adds the values to an array field if they doesn't already exist in the arrayUpdateraddToSet(String field, Object value)adds the value to an array field if it doesn't already exist in the arrayUpdateraddToSet(String field, List<?> values)adds the values to an array field if they doesn't already exist in the arrayUpdaterdec(String field)Decrements the numeric field by 1Updaterdec(String field, Number value)Decrements the numeric field by value (must be a positive Double, Float, Long, or Integer).UpdaterdisableValidation()Turns off validation (for all calls made after)UpdaterenableValidation()Turns on validation (for all calls made after); by default validation is onUpdaterinc(String field)Increments the numeric field by 1Updaterinc(String field, Number value)increments the numeric field by value (negatives are allowed)Updatermax(String field, Number value)Sets the numeric field to value if it is greater than the current value.Updatermin(String field, Number value)sets the numeric field to value if it is less than the current value.Updaterpull(String field, Object value)removes the value from the array fieldUpdaterpullAll(String field, List<?> values)removes the values from the array fieldUpdaterpush(String field, Object value)Adds new values to an array field.Updaterpush(String field, Object value, PushOptions options)Adds new values to an array field at the given positionUpdaterpush(String field, List<?> values)Adds new values to an array field.Updaterpush(String field, List<?> values, PushOptions options)Adds new values to an array field at the given positiondefault UpdaterremoveAll(String field, Object value)Deprecated, for removal: This API element is subject to removal in a future version.usepull(String, Object)insteaddefault UpdaterremoveAll(String field, List<?> values)Deprecated, for removal: This API element is subject to removal in a future version.usepullAll(String, List)insteadUpdaterremoveFirst(String field)removes the first value from the arrayUpdaterremoveLast(String field)removes the last value from the arrayUpdaterset(Object entity)sets the entity value to completely replace the stored documentUpdaterset(String field, Object value)sets the field valueUpdatersetOnInsert(String field, Object value)sets the field on insert.Updaterunset(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
-
-