T - the type to updatepublic class UpdateOpsImpl<T> extends Object implements UpdateOperations<T>
| Constructor and Description |
|---|
UpdateOpsImpl(Class<T> type,
Mapper mapper)
Creates an UpdateOpsImpl for the type given.
|
| Modifier and Type | Method and Description |
|---|---|
UpdateOperations<T> |
add(String fieldExpr,
Object value)
adds the value to an array field
|
UpdateOperations<T> |
add(String fieldExpr,
Object value,
boolean addDups)
adds the value to an array field
|
protected void |
add(UpdateOperator op,
String f,
Object value,
boolean convert) |
UpdateOperations<T> |
addAll(String fieldExpr,
List<?> values,
boolean addDups)
adds the values to an array field
|
UpdateOperations<T> |
dec(String field)
Decrements the numeric field by 1
|
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 on
|
DBObject |
getOps() |
UpdateOperations<T> |
inc(String field)
Increments the numeric field by 1
|
UpdateOperations<T> |
inc(String field,
Number value)
increments the numeric field by value (negatives are allowed)
|
boolean |
isIsolated() |
UpdateOperations<T> |
isolated()
Enables isolation (so this update happens in one shot, without yielding)
|
UpdateOperations<T> |
max(String field,
Number value)
Sets the numeric field to value if it is greater than the current value.
|
UpdateOperations<T> |
min(String field,
Number value)
sets the numeric field to value if it is less than the current value.
|
protected UpdateOperations<T> |
remove(String fieldExpr,
boolean firstNotLast) |
UpdateOperations<T> |
removeAll(String field,
List<?> values)
removes the values from the array field
|
UpdateOperations<T> |
removeAll(String field,
Object value)
removes the value from the array field
|
UpdateOperations<T> |
removeFirst(String field)
removes the first value from the array
|
UpdateOperations<T> |
removeLast(String field)
removes the last value from the array
|
UpdateOperations<T> |
set(String field,
Object value)
sets the field value
|
UpdateOperations<T> |
setOnInsert(String field,
Object value)
sets the field on insert.
|
void |
setOps(DBObject ops)
Sets the operations for this UpdateOpsImpl
|
protected List<Object> |
toDBObjList(MappedField mf,
List<?> values) |
UpdateOperations<T> |
unset(String field)
removes the field
|
public UpdateOperations<T> add(String fieldExpr, Object value)
UpdateOperationsadd in interface UpdateOperations<T>fieldExpr - the field to updatevalue - the value to addpublic UpdateOperations<T> add(String fieldExpr, Object value, boolean addDups)
UpdateOperationsadd in interface UpdateOperations<T>fieldExpr - the field to updatevalue - the value to addaddDups - if true, the value will be added even if it already exists in the array ($push)public UpdateOperations<T> addAll(String fieldExpr, List<?> values, boolean addDups)
UpdateOperationsaddAll in interface UpdateOperations<T>fieldExpr - the field to updatevalues - the values to addaddDups - if true, the values will be added even if they already exists in the array ($push)public UpdateOperations<T> dec(String field)
UpdateOperationsdec in interface UpdateOperations<T>field - the field to updatepublic UpdateOperations<T> disableValidation()
UpdateOperationsdisableValidation in interface UpdateOperations<T>public UpdateOperations<T> enableValidation()
UpdateOperationsenableValidation in interface UpdateOperations<T>public UpdateOperations<T> inc(String field)
UpdateOperationsinc in interface UpdateOperations<T>field - the field to updatepublic UpdateOperations<T> inc(String field, Number value)
UpdateOperationsinc in interface UpdateOperations<T>field - the field to updatevalue - the value to increment bypublic UpdateOperations<T> isolated()
UpdateOperationsisolated in interface UpdateOperations<T>public UpdateOperations<T> max(String field, Number value)
UpdateOperationsmax in interface UpdateOperations<T>field - the field to updatevalue - the value to usepublic UpdateOperations<T> min(String field, Number value)
UpdateOperationsmin in interface UpdateOperations<T>field - the field to updatevalue - the value to usepublic UpdateOperations<T> removeAll(String field, Object value)
UpdateOperationsremoveAll in interface UpdateOperations<T>field - the field to updatevalue - the value to usepublic UpdateOperations<T> removeAll(String field, List<?> values)
UpdateOperationsremoveAll in interface UpdateOperations<T>field - the field to updatevalues - the values to usepublic UpdateOperations<T> removeFirst(String field)
UpdateOperationsremoveFirst in interface UpdateOperations<T>field - the field to updatepublic UpdateOperations<T> removeLast(String field)
UpdateOperationsremoveLast in interface UpdateOperations<T>field - the field to updatepublic UpdateOperations<T> set(String field, Object value)
UpdateOperationsset in interface UpdateOperations<T>field - the field to updatevalue - the value to usepublic UpdateOperations<T> setOnInsert(String field, Object value)
UpdateOperationssetOnInsert in interface UpdateOperations<T>field - the field to updatevalue - the value to usepublic UpdateOperations<T> unset(String field)
UpdateOperationsunset in interface UpdateOperations<T>field - the field to updatepublic DBObject getOps()
public void setOps(DBObject ops)
ops - the operationspublic boolean isIsolated()
protected void add(UpdateOperator op, String f, Object value, boolean convert)
protected UpdateOperations<T> remove(String fieldExpr, boolean firstNotLast)
protected List<Object> toDBObjList(MappedField mf, List<?> values)