Package com.mongodb.client.model
Class Updates
- java.lang.Object
-
- com.mongodb.client.model.Updates
-
@Deprecated(since="2021-05-27") public final class Updates extends java.lang.Object
Deprecated.Usage of this API is not supported in AEM as a Cloud Service.A factory for document updates. A convenient way to use this class is to statically import all of its methods, which allows usage like:collection.updateOne(eq("x", 1), set("x", 2));
- Since:
- 3.1
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <TItem> Bson
addEachToSet(java.lang.String fieldName, java.util.List<TItem> values)
Deprecated.Creates an update that adds each of the given values to the array value of the field with the given name, unless the value is already present, in which case it does nothingstatic <TItem> Bson
addToSet(java.lang.String fieldName, TItem value)
Deprecated.Creates an update that adds the given value to the array value of the field with the given name, unless the value is already present, in which case it does nothingstatic Bson
bitwiseAnd(java.lang.String fieldName, int value)
Deprecated.Creates an update that performs a bitwise and between the given integer value and the integral value of the field with the given name.static Bson
bitwiseAnd(java.lang.String fieldName, long value)
Deprecated.Creates an update that performs a bitwise and between the given long value and the integral value of the field with the given name.static Bson
bitwiseOr(java.lang.String fieldName, int value)
Deprecated.Creates an update that performs a bitwise or between the given integer value and the integral value of the field with the given name.static Bson
bitwiseOr(java.lang.String fieldName, long value)
Deprecated.Creates an update that performs a bitwise or between the given long value and the integral value of the field with the given name.static Bson
bitwiseXor(java.lang.String fieldName, int value)
Deprecated.Creates an update that performs a bitwise xor between the given integer value and the integral value of the field with the given name.static Bson
bitwiseXor(java.lang.String fieldName, long value)
Deprecated.Creates an update that performs a bitwise xor between the given long value and the integral value of the field with the given name.static Bson
combine(java.util.List<? extends Bson> updates)
Deprecated.Combine a list of updates into a single update.static Bson
combine(Bson... updates)
Deprecated.Combine a list of updates into a single update.static Bson
currentDate(java.lang.String fieldName)
Deprecated.Creates an update that sets the value of the field to the current date as a BSON date.static Bson
currentTimestamp(java.lang.String fieldName)
Deprecated.Creates an update that sets the value of the field to the current date as a BSON timestamp.static Bson
inc(java.lang.String fieldName, java.lang.Number number)
Deprecated.Creates an update that increments the value of the field with the given name by the given value.static <TItem> Bson
max(java.lang.String fieldName, TItem value)
Deprecated.Creates an update that sets the value of the field to the given value if the given value is greater than the current value of the field.static <TItem> Bson
min(java.lang.String fieldName, TItem value)
Deprecated.Creates an update that sets the value of the field to the given value if the given value is less than the current value of the field.static Bson
mul(java.lang.String fieldName, java.lang.Number number)
Deprecated.Creates an update that multiplies the value of the field with the given name by the given number.static Bson
popFirst(java.lang.String fieldName)
Deprecated.Creates an update that pops the first element of an array that is the value of the field with the given name.static Bson
popLast(java.lang.String fieldName)
Deprecated.Creates an update that pops the last element of an array that is the value of the field with the given name.static <TItem> Bson
pull(java.lang.String fieldName, TItem value)
Deprecated.Creates an update that removes all instances of the given value from the array value of the field with the given name.static <TItem> Bson
pullAll(java.lang.String fieldName, java.util.List<TItem> values)
Deprecated.Creates an update that removes all instances of the given values from the array value of the field with the given name.static Bson
pullByFilter(Bson filter)
Deprecated.Creates an update that removes from an array all elements that match the given filter.static <TItem> Bson
push(java.lang.String fieldName, TItem value)
Deprecated.Creates an update that adds the given value to the array value of the field with the given name.static <TItem> Bson
pushEach(java.lang.String fieldName, java.util.List<TItem> values)
Deprecated.Creates an update that adds each of the given values to the array value of the field with the given name.static <TItem> Bson
pushEach(java.lang.String fieldName, java.util.List<TItem> values, PushOptions options)
Deprecated.Creates an update that adds each of the given values to the array value of the field with the given name, applying the given options for positioning the pushed values, and then slicing and/or sorting the array.static Bson
rename(java.lang.String fieldName, java.lang.String newFieldName)
Deprecated.Creates an update that renames a field.static <TItem> Bson
set(java.lang.String fieldName, TItem value)
Deprecated.Creates an update that sets the value of the field with the given name to the given value.static <TItem> Bson
setOnInsert(java.lang.String fieldName, TItem value)
Deprecated.Creates an update that sets the value of the field with the given name to the given value, but only if the update is an upsert that results in an insert of a document.static Bson
setOnInsert(Bson value)
Deprecated.Creates an update that sets the values for the document, but only if the update is an upsert that results in an insert of a document.static Bson
unset(java.lang.String fieldName)
Deprecated.Creates an update that deletes the field with the given name.
-
-
-
Method Detail
-
combine
public static Bson combine(Bson... updates)
Deprecated.Combine a list of updates into a single update.- Parameters:
updates
- the list of updates- Returns:
- a combined update
-
combine
public static Bson combine(java.util.List<? extends Bson> updates)
Deprecated.Combine a list of updates into a single update.- Parameters:
updates
- the list of updates- Returns:
- a combined update
-
set
public static <TItem> Bson set(java.lang.String fieldName, @Nullable TItem value)
Deprecated.Creates an update that sets the value of the field with the given name to the given value.- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalue
- the value, which may be null- Returns:
- the update
-
unset
public static Bson unset(java.lang.String fieldName)
Deprecated.Creates an update that deletes the field with the given name.- Parameters:
fieldName
- the non-null field name- Returns:
- the update
-
setOnInsert
public static Bson setOnInsert(Bson value)
Deprecated.Creates an update that sets the values for the document, but only if the update is an upsert that results in an insert of a document.- Parameters:
value
- the value- Returns:
- the update
- Since:
- 3.10.0
- See Also:
UpdateOptions.upsert(boolean)
-
setOnInsert
public static <TItem> Bson setOnInsert(java.lang.String fieldName, @Nullable TItem value)
Deprecated.Creates an update that sets the value of the field with the given name to the given value, but only if the update is an upsert that results in an insert of a document.- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalue
- the value, which may be null- Returns:
- the update
- See Also:
UpdateOptions.upsert(boolean)
-
rename
public static Bson rename(java.lang.String fieldName, java.lang.String newFieldName)
Deprecated.Creates an update that renames a field.- Parameters:
fieldName
- the non-null field namenewFieldName
- the non-null new field name- Returns:
- the update
-
inc
public static Bson inc(java.lang.String fieldName, java.lang.Number number)
Deprecated.Creates an update that increments the value of the field with the given name by the given value.- Parameters:
fieldName
- the non-null field namenumber
- the value- Returns:
- the update
-
mul
public static Bson mul(java.lang.String fieldName, java.lang.Number number)
Deprecated.Creates an update that multiplies the value of the field with the given name by the given number.- Parameters:
fieldName
- the non-null field namenumber
- the non-null number- Returns:
- the update
-
min
public static <TItem> Bson min(java.lang.String fieldName, TItem value)
Deprecated.Creates an update that sets the value of the field to the given value if the given value is less than the current value of the field.- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalue
- the value- Returns:
- the update
-
max
public static <TItem> Bson max(java.lang.String fieldName, TItem value)
Deprecated.Creates an update that sets the value of the field to the given value if the given value is greater than the current value of the field.- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalue
- the value- Returns:
- the update
-
currentDate
public static Bson currentDate(java.lang.String fieldName)
Deprecated.Creates an update that sets the value of the field to the current date as a BSON date.- Parameters:
fieldName
- the non-null field name- Returns:
- the update
-
currentTimestamp
public static Bson currentTimestamp(java.lang.String fieldName)
Deprecated.Creates an update that sets the value of the field to the current date as a BSON timestamp.- Parameters:
fieldName
- the non-null field name- Returns:
- the update
-
addToSet
public static <TItem> Bson addToSet(java.lang.String fieldName, @Nullable TItem value)
Deprecated.Creates an update that adds the given value to the array value of the field with the given name, unless the value is already present, in which case it does nothing- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalue
- the value, which may be null- Returns:
- the update
-
addEachToSet
public static <TItem> Bson addEachToSet(java.lang.String fieldName, java.util.List<TItem> values)
Deprecated.Creates an update that adds each of the given values to the array value of the field with the given name, unless the value is already present, in which case it does nothing- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalues
- the values- Returns:
- the update
-
push
public static <TItem> Bson push(java.lang.String fieldName, @Nullable TItem value)
Deprecated.Creates an update that adds the given value to the array value of the field with the given name.- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalue
- the value, which may be null- Returns:
- the update
-
pushEach
public static <TItem> Bson pushEach(java.lang.String fieldName, java.util.List<TItem> values)
Deprecated.Creates an update that adds each of the given values to the array value of the field with the given name.- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalues
- the values- Returns:
- the update
-
pushEach
public static <TItem> Bson pushEach(java.lang.String fieldName, java.util.List<TItem> values, PushOptions options)
Deprecated.Creates an update that adds each of the given values to the array value of the field with the given name, applying the given options for positioning the pushed values, and then slicing and/or sorting the array.- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalues
- the valuesoptions
- the non-null push options- Returns:
- the update
-
pull
public static <TItem> Bson pull(java.lang.String fieldName, @Nullable TItem value)
Deprecated.Creates an update that removes all instances of the given value from the array value of the field with the given name.- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalue
- the value, which may be null- Returns:
- the update
-
pullByFilter
public static Bson pullByFilter(Bson filter)
Deprecated.Creates an update that removes from an array all elements that match the given filter.- Parameters:
filter
- the query filter- Returns:
- the update
-
pullAll
public static <TItem> Bson pullAll(java.lang.String fieldName, java.util.List<TItem> values)
Deprecated.Creates an update that removes all instances of the given values from the array value of the field with the given name.- Type Parameters:
TItem
- the value type- Parameters:
fieldName
- the non-null field namevalues
- the values- Returns:
- the update
-
popFirst
public static Bson popFirst(java.lang.String fieldName)
Deprecated.Creates an update that pops the first element of an array that is the value of the field with the given name.- Parameters:
fieldName
- the non-null field name- Returns:
- the update
-
popLast
public static Bson popLast(java.lang.String fieldName)
Deprecated.Creates an update that pops the last element of an array that is the value of the field with the given name.- Parameters:
fieldName
- the non-null field name- Returns:
- the update
-
bitwiseAnd
public static Bson bitwiseAnd(java.lang.String fieldName, int value)
Deprecated.Creates an update that performs a bitwise and between the given integer value and the integral value of the field with the given name.- Parameters:
fieldName
- the field namevalue
- the value- Returns:
- the update
-
bitwiseAnd
public static Bson bitwiseAnd(java.lang.String fieldName, long value)
Deprecated.Creates an update that performs a bitwise and between the given long value and the integral value of the field with the given name.- Parameters:
fieldName
- the field namevalue
- the value- Returns:
- the update
-
bitwiseOr
public static Bson bitwiseOr(java.lang.String fieldName, int value)
Deprecated.Creates an update that performs a bitwise or between the given integer value and the integral value of the field with the given name.- Parameters:
fieldName
- the field namevalue
- the value- Returns:
- the update
-
bitwiseOr
public static Bson bitwiseOr(java.lang.String fieldName, long value)
Deprecated.Creates an update that performs a bitwise or between the given long value and the integral value of the field with the given name.- Parameters:
fieldName
- the field namevalue
- the value- Returns:
- the update
-
bitwiseXor
public static Bson bitwiseXor(java.lang.String fieldName, int value)
Deprecated.Creates an update that performs a bitwise xor between the given integer value and the integral value of the field with the given name.- Parameters:
fieldName
- the field namevalue
- the value- Returns:
- the update
-
bitwiseXor
public static Bson bitwiseXor(java.lang.String fieldName, long value)
Deprecated.Creates an update that performs a bitwise xor between the given long value and the integral value of the field with the given name.- Parameters:
fieldName
- the field namevalue
- the value- Returns:
- the update
-
-