- Must include a unique
_idfield - Must conform to the schema defined for the collection
Upsert documents
To upsert documents, pass a list of documents to theupsert() function:
- Every document must have a string
_idfield. - If a document with the specified
_iddoesn’t exist, a new document will be inserted. - If a document with the same
_idalready exists, the existing document will be replaced with the new one.
The
upsert() function does not perform a partial update or merge - the entire document is being replaced.Additional (non-schema) fields
You may include fields that are not defined in the collection schema. These fields:- Are stored with the document
- Can be returned to the client in query results
- Can be used for filtering in queries
Supported types
TopK documents are a flat structure of key-value pairs. The following value types are supported:Delete documents
You can delete documents by their_id or using a filter expression. Both methods provide
the same consistency guarantees and will be reflected in query/get results according to your consistency level.
Delete documents by _id
To delete documents by their _id, pass a list of _ids to the delete() method:
The
delete() method returns an LSN (Log Sequence Number) that you can pass to subsequent queries for read-after-write consistency.Delete documents by filter expression
To delete documents that match a predicate, you can pass a filter expression to thedelete() function.