com.mysql.cj.xdevapi

## Interface ModifyStatement

All Superinterfaces:
  Statement<ModifyStatement,Result>

    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

All Methods Instance Methods Abstract Methods
`ModifyStatement` `arrayAppend(String docPath, Object value)` Append a value to the specified array.
`ModifyStatement` `arrayInsert(String docPath, Object value)` Insert a value into the specified array.
`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.
`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(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(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.
`ModifyStatement` `sort(String... sortFields)` Add/replace the order specification for this statement.
`ModifyStatement` `unset(String... docPath)` Nullify the given fields.

### Methods inherited from interface com.mysql.cj.xdevapi.Statement

`bind, bind, bind, bind, clearBindings, execute, executeAsync`

### Method Detail

#### sort

    ModifyStatement sort(String... sortFields)

Add/replace the order specification for this statement.

Parameters:
  `sortFields` - sort expression
Returns:
  `ModifyStatement`

#### limit

    ModifyStatement limit(long numberOfRows)

Add/replace the document limit for this statement.

Parameters:
  `numberOfRows` - limit
Returns:
  `ModifyStatement`

#### set

    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` - document path to the given value
  `value` - value to set
Returns:
  `ModifyStatement`

#### change

    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` - document path to the given value
  `value` - value to set
Returns:
  `ModifyStatement`

#### unset

    ModifyStatement unset(String... docPath)

Nullify the given fields.

Parameters:
  `docPath` - one or more field names
Returns:
  `ModifyStatement`

#### patch

    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` - patch object
Returns:
  `ModifyStatement`

#### patch

    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` - patch object
Returns:
  `ModifyStatement`

#### arrayInsert

    ModifyStatement arrayInsert(String docPath,
                                Object value)

Insert a value into the specified array.

Parameters:
  `docPath` - document path to the array field
  `value` - value to insert
Returns:
  `ModifyStatement`

#### arrayAppend

    ModifyStatement arrayAppend(String docPath,
                                Object value)

Append a value to the specified array.

Parameters:
  `docPath` - document path to the array field
  `value` - value to append
Returns:
  `ModifyStatement`

Copyright © 2016, 2022, Oracle and/or its affiliates.