Trait bonsaidb::core::schema::CollectionViewSchema[][src]

pub trait CollectionViewSchema: 'static + Send + Sync + Debug where
    <Self::View as View>::Collection: SerializedCollection
{ type View: SerializedView; fn map(
        document: CollectionDocument<<Self::View as View>::Collection>
    ) -> Result<Mappings<<Self::View as View>::Key, <Self::View as View>::Value>, Error>; fn unique(&self) -> bool { ... }
fn version(&self) -> u64 { ... }
fn reduce(
        mappings: &[MappedValue<<Self::View as View>::Key, <Self::View as View>::Value>],
        rereduce: bool
    ) -> Result<<Self::View as View>::Value, Error> { ... } }
Expand description

A View for a Collection that stores Serde-compatible documents. The only difference between implmementing this and View is that the map function receives a CollectionDocument instead of a BorrowedDocument.

Associated Types

The view this schema is an implementation of.

Required methods

The map function for this view. This function is responsible for emitting entries for any documents that should be contained in this View. If None is returned, the View will not include the document.

Provided methods

If true, no two documents may emit the same key. Unique views are updated when the document is saved, allowing for this check to be done atomically. When a document is updated, all unique views will be updated, and if any of them fail, the document will not be allowed to update and an Error::UniqueKeyViolation will be returned.

The version of the view. Changing this value will cause indexes to be rebuilt.

The reduce function for this view. If Err(Error::ReduceUnimplemented) is returned, queries that ask for a reduce operation will return an error. See CouchDB’s Reduce/Rereduce documentation for the design this implementation will be inspired by