Module bonsaidb_core::document

source ·
Expand description

Types for interacting with Documents.

A document is a stored value in a Collection. Each document has a Header, which contains a unique ID and information about the currently stored revision. BonsaiDb adds extra protections by requiring update operations to include the document’s current header. If the document header doesn’t match the currently stored information, Error::DocumentConflict will be returned.

The lower-level interface for BonsaiDb uses OwnedDocument and BorrowedDocument. These types contain a buffer of bytes that have been inserted into a collection previously. This interface is useful if you are wanting to do borrowing or zero-copy deserialization, as the handling of the bytes is left up to the user. Views implemented using ViewSchema receive a BorrowedDocument parameter to the map function.

The higher-level interface uses CollectionDocument<T> which automatically serializes and deserialized from OwnedDocument/BorrowedDocument using the SerializedCollection trait. This interface is recommended for most users, as it is significantly more ergonomic. Views implemented using CollectionMapReduce receive a CollectionDocument<T> parameter to the map function.

Structs

Enums

  • A header with either a serialized or deserialized primary key.
  • The ID of an encryption key.

Traits