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

      ModifyStatement sort​(java.lang.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​(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.
      Parameters:
      docPath - document path to the given value
      value - value to set
      Returns:
      ModifyStatement
    • change

      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.
      Parameters:
      docPath - document path to the given value
      value - value to set
      Returns:
      ModifyStatement
    • unset

      ModifyStatement unset​(java.lang.String... fields)
      Nullify the given fields.
      Parameters:
      fields - 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​(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. 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​(java.lang.String field, java.lang.Object value)
      Insert a value into the specified array.
      Parameters:
      field - document path to the array field
      value - value to insert
      Returns:
      ModifyStatement
    • arrayAppend

      ModifyStatement arrayAppend​(java.lang.String field, java.lang.Object value)
      Append a value to the specified array.
      Parameters:
      field - document path to the array field
      value - value to append
      Returns:
      ModifyStatement