Top Description Methods
com.mysql.cj.xdevapi

public Interface ModifyStatement

extends Statement<ModifyStatement, Result>
Known Direct Implementers
com.mysql.cj.xdevapi.ModifyStatementImpl

A statement representing a set of document modifications.

Method Summary

Modifier and TypeMethod and Description
public ModifyStatement
arrayAppend(String
document path to the array field
docPath
,
Object
value to append
value
)

Append a value to the specified array.

public ModifyStatement
arrayInsert(String
document path to the array field
docPath
,
Object
value to insert
value
)

Insert a value into the specified array.

public ModifyStatement
change(String
document path to the given value
docPath
,
Object
value to set
value
)

Add an update to the statement setting the field, if it exists at the document path, to the given value.

public ModifyStatement
limit(long
limit
numberOfRows
)

Add/replace the document limit for this statement.

public ModifyStatement
patch(DbDoc
patch object
document
)

Takes in a patch object and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function.

public ModifyStatement
patch(String
patch object
document
)

Takes in a document patch and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function.

public ModifyStatement
set(String
document path to the given value
docPath
,
Object
value to set
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.

public ModifyStatement
sort(String...
sort expression
sortFields
)

Add/replace the order specification for this statement.

public ModifyStatement
unset(String...
one or more field names
docPath
)

Nullify the given fields.

Inherited from com.mysql.cj.xdevapi.Statement:
bindbindbindbindclearBindingsexecuteexecuteAsync

Method Detail

arrayAppendback to summary
public ModifyStatement arrayAppend(String docPath, Object value)

Append a value to the specified array.

Parameters
docPath:String

document path to the array field

value:Object

value to append

Returns:ModifyStatement

ModifyStatement

arrayInsertback to summary
public ModifyStatement arrayInsert(String docPath, Object value)

Insert a value into the specified array.

Parameters
docPath:String

document path to the array field

value:Object

value to insert

Returns:ModifyStatement

ModifyStatement

changeback to summary
public ModifyStatement change(String docPath, Object value)

Add an update to the statement setting the field, if it exists at the document path, to the given value.

Parameters
docPath:String

document path to the given value

value:Object

value to set

Returns:ModifyStatement

ModifyStatement

limitback to summary
public ModifyStatement limit(long numberOfRows)

Add/replace the document limit for this statement.

Parameters
numberOfRows:long

limit

Returns:ModifyStatement

ModifyStatement

patchback to summary
public 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. Please note that DbDoc does not support expressions as a field values, please use patch(String) method if you need such functionality.

Parameters
document:DbDoc

patch object

Returns:ModifyStatement

ModifyStatement

patchback to summary
public ModifyStatement patch(String document)

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:String

patch object

Returns:ModifyStatement

ModifyStatement

setback to summary
public ModifyStatement set(String docPath, 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.

Parameters
docPath:String

document path to the given value

value:Object

value to set

Returns:ModifyStatement

ModifyStatement

sortback to summary
public ModifyStatement sort(String... sortFields)

Add/replace the order specification for this statement.

Parameters
sortFields:String[]

sort expression

Returns:ModifyStatement

ModifyStatement

unsetback to summary
public ModifyStatement unset(String... docPath)

Nullify the given fields.

Parameters
docPath:String[]

one or more field names

Returns:ModifyStatement

ModifyStatement