Module document

Module 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§

BorrowedDocument
Contains a serialized document in the database.
CollectionDocument
A document with serializable contents.
CollectionHeader
A header for a CollectionDocument.
DocumentId
The serialized representation of a document’s unique ID.
Header
The header of a Document.
InvalidHexadecimal
An invalid hexadecimal character was encountered.
OwnedDocument
Contains a serialized document in the database.
Revision
Information about a Document’s revision history.

Enums§

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

Traits§

Document
Common interface of a document in BonsaiDb.
Emit
View mapping emit functions. Used when implementing a view’s map() function.
HasHeader
A type that can return a Header.
OwnedDocuments
Helper functions for a slice of OwnedDocuments.