MySQL Shell API 8.0.40
Unified development interface for MySQL Products
|
Handler for document addition on a Collection. More...
Methods | |
CollectionAdd | add (DocDefinition document[, DocDefinition document,...]) |
Stores documents to be added into a collection. More... | |
Result | execute () |
Executes the add operation, the documents are added to the target collection. More... | |
Handler for document addition on a Collection.
This object provides the necessary functions to allow adding documents into a collection.
This object should only be created by calling any of the add functions on the collection object where the documents will be added.
CollectionAdd add | ( | DocDefinition | document[, DocDefinition document,...] | ) |
Stores documents to be added into a collection.
This function receives one or more document definitions to be added into a collection. The documents are cached in an internal list and are added to the collection when the execute() method is called.
A document definition may be provided in two ways:
There are three ways to add multiple documents:
To be added, every document must have a string property named '_id' ideally with a universal unique identifier (UUID) as value. If the '_id' property is missing, it is automatically set with an internally generated UUID.
This method can be called many times, every time it is called the received document(s) will be cached into an internal list. The actual addition into the collection will occur only when the execute() method is called.
Result execute | ( | ) |
Executes the add operation, the documents are added to the target collection.
This function can be invoked once after:
Adding document using an existing document list
Adding document using a separate parameter for each document on a single call to add(...)
Adding documents using chained calls to add(...)
JSON as Document Expressions
A document can be represented as a JSON expression as follows: