Enum bonsaidb_core::transaction::Command
source · pub enum Command {
Insert {
id: Option<DocumentId>,
contents: Bytes,
},
Update {
header: Header,
contents: Bytes,
},
Overwrite {
id: DocumentId,
contents: Bytes,
},
Delete {
header: Header,
},
Check {
id: DocumentId,
revision: Option<Revision>,
},
}Expand description
A command to execute within a Collection.
Variants§
Insert
Fields
id: Option<DocumentId>An optional id for the document. If this is None, a unique id will
be generated. If this is Some() and a document already exists with
that id, a conflict error will be returned.
contents: BytesThe initial contents of the document.
Inserts a new document containing contents.
Update
Fields
contents: BytesThe new contents to store within the Document.
Update an existing Document identified by header. header.revision must match
the currently stored revision on the Document. If it does not, the
command fill fail with a DocumentConflict error.
Overwrite
Fields
id: DocumentIdThe id of the document to overwrite.
contents: BytesThe new contents to store within the Document.
Overwrite an existing Document identified by id. The revision will
not be checked before the document is updated. If the document does not
exist, it will be created.
Delete
Delete an existing Document identified by id. revision must match
the currently stored revision on the Document. If it does not, the
command fill fail with a DocumentConflict error.
Check
Fields
id: DocumentIdThe id of the document to check.
Checks whether a document exists, and optionally whether its revision is
still current. If the document is not found, a DocumentNotFound error
will be returned. If the document revision is provided and does not
match, a DocumentConflict error will be returned.