Package com.mysql.cj.xdevapi
Interface ModifyStatement
- All Superinterfaces:
Statement<ModifyStatement,Result>
- All Known Implementing Classes:
ModifyStatementImpl
public interface ModifyStatement extends Statement<ModifyStatement,Result>
A statement representing a set of document modifications.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.mysql.cj.xdevapi.Statement
Statement.LockContention
-
Method Summary
Modifier and Type Method Description ModifyStatement
arrayAppend(java.lang.String field, java.lang.Object value)
Append a value to the specified array.ModifyStatement
arrayInsert(java.lang.String field, java.lang.Object value)
Insert a value into the specified array.ModifyStatement
change(java.lang.String docPath, java.lang.Object value)
Add an update to the statement setting the field, if it exists at the document path, to the given value.ModifyStatement
limit(long numberOfRows)
Add/replace the document limit for this statement.ModifyStatement
patch(DbDoc document)
Takes in a patch object and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function.ModifyStatement
patch(java.lang.String document)
Takes in a document patch and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function.ModifyStatement
set(java.lang.String docPath, java.lang.Object value)
Add an update to the statement setting the field as the document path to the given value for all documents matching the search criteria.ModifyStatement
sort(java.lang.String... sortFields)
Add/replace the order specification for this statement.ModifyStatement
unset(java.lang.String... fields)
Nullify the given fields.Methods inherited from interface com.mysql.cj.xdevapi.Statement
bind, bind, bind, bind, clearBindings, execute, executeAsync
-
Method Details
-
sort
Add/replace the order specification for this statement.- Parameters:
sortFields
- sort expression- Returns:
ModifyStatement
-
limit
Add/replace the document limit for this statement.- Parameters:
numberOfRows
- limit- Returns:
ModifyStatement
-
set
Add an update to the statement setting the field as the document path to the given value for all documents matching the search criteria.- Parameters:
docPath
- document path to the given valuevalue
- value to set- Returns:
ModifyStatement
-
change
Add an update to the statement setting the field, if it exists at the document path, to the given value.- Parameters:
docPath
- document path to the given valuevalue
- value to set- Returns:
ModifyStatement
-
unset
Nullify the given fields.- Parameters:
fields
- one or more field names- Returns:
ModifyStatement
-
patch
Takes in a patch object and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function. Please note thatDbDoc
does not support expressions as a field values, please usepatch(String)
method if you need such functionality.- Parameters:
document
- patch object- Returns:
ModifyStatement
-
patch
Takes in a document patch and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function. A document patch is similar to a JSON object, with the key difference that document field values can be nested expressions in addition to literal values.
Example:
collection.modify("_id = :id")
.patch("{\"zip\": address.zip-300000, \"street\": CONCAT($.name, '''s street: ', $.address.street)}")
.bind("id", "2").execute();- Parameters:
document
- patch object- Returns:
ModifyStatement
-
arrayInsert
Insert a value into the specified array.- Parameters:
field
- document path to the array fieldvalue
- value to insert- Returns:
ModifyStatement
-
arrayAppend
Append a value to the specified array.- Parameters:
field
- document path to the array fieldvalue
- value to append- Returns:
ModifyStatement
-