MySQL Connector/C++ 9.1.0
MySQL connector library for C and C++ applications
|
An operation which modifies all or selected documents in a collection. More...
Public Member Functions | |
CollectionModify (Collection &coll, const string &expr) | |
Create an operation which modifies selected documents in the given collection. More... | |
CollectionModify & | set (const Field &field, const Value &val) |
Set the given field in a document to the given value. More... | |
CollectionModify & | unset (const Field &field) |
Remove the given field from a document. More... | |
CollectionModify & | arrayInsert (const Field &field, const Value &val) |
Insert a value into an array field of a document. More... | |
CollectionModify & | arrayAppend (const Field &field, const Value &val) |
Append a value to an array field of a document. More... | |
CollectionModify & | patch (const string &val) |
Apply JSON Patch to a target JSON document. More... | |
Operation & | sort (Type... spec) |
Specify ordering of documents in a query results. More... | |
Operation & | limit (unsigned items) |
Limit the operation to the given number of items (rows or documents). | |
An operation which modifies all or selected documents in a collection.
Note that in operations such as set()
, unset()
, arrayInsert()
and arrayAppend()
the field argument is specified as a document path. It can be a simple field name, but it can be a more complex expression like $.foo.bar[3]
. One consequence of this is that document field names that contain spaces or other special characters need to be quoted, for example one needs to use this form
as .unset("field name with spaces")
would be an invalid document path expression.
Note also that wildcard paths that use *
or **
are not valid for these operations that modify documents.
See MySQL Reference Manual for more information on document path syntax supported by MySQL server.
|
inline |
Create an operation which modifies selected documents in the given collection.
Documents to be modified are specified by the given Boolean expression.
|
inline |
Set the given field in a document to the given value.
The field is given by a document path. The value can be either a direct literal, DbDoc
instance or an expression given as expr(<string>)
, to be evaluated on the server.
|
inline |
Remove the given field from a document.
The field is given by a document path.
|
inline |
Insert a value into an array field of a document.
The field
parameter should be a document path pointing at a location inside an array field. The given value is inserted at this position.
|
inline |
Append a value to an array field of a document.
The field
parameter should be a document path pointing at an array field inside the document. The given value is appended at the end of the array.
|
inline |
Apply JSON Patch to a target JSON document.
The JSON Patch format is defined by RFC7386.
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.
The patch contains instructions of how the source document is to be modified producing a derived document. By default, all fields from the source document are copied to the resulting document. If patch sets a field to NULL, the field of that name in the source is skipped from the result, identifiers and function calls are evaluated against the original source document.
|
inlineinherited |
Specify ordering of documents in a query results.
Arguments are one or more strings of the form "<expr> <dir>"
where <expr>
gives the value to sort on and <dir>
is a sorting direction ASC
or DESC
.