Trait bonsaidb::core::schema::view::CollectionMapReduce
pub trait CollectionMapReduce: ViewSchemawhere
<Self::View as View>::Collection: SerializedCollection,{
// Required method
fn map<'doc>(
&self,
document: CollectionDocument<<Self::View as View>::Collection>
) -> Result<Mappings<Self::MappedKey<'doc>, <Self::View as View>::Value>, Error>
where CollectionDocument<<Self::View as View>::Collection>: 'doc;
// Provided method
fn reduce(
&self,
mappings: &[MappedValue<Self::MappedKey<'_>, <Self::View as View>::Value>],
rereduce: bool
) -> Result<<Self::View as View>::Value, Error> { ... }
}
Expand description
A MapReduce
implementation that automatically serializes/deserializes
using CollectionDocument
and SerializedCollection
.
Implementing this trait automatically implements ViewSchema
for the same
type.
Required Methods§
fn map<'doc>(
&self,
document: CollectionDocument<<Self::View as View>::Collection>
) -> Result<Mappings<Self::MappedKey<'doc>, <Self::View as View>::Value>, Error>where
CollectionDocument<<Self::View as View>::Collection>: 'doc,
fn map<'doc>( &self, document: CollectionDocument<<Self::View as View>::Collection> ) -> Result<Mappings<Self::MappedKey<'doc>, <Self::View as View>::Value>, Error>where CollectionDocument<<Self::View as View>::Collection>: 'doc,
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§
fn reduce(
&self,
mappings: &[MappedValue<Self::MappedKey<'_>, <Self::View as View>::Value>],
rereduce: bool
) -> Result<<Self::View as View>::Value, Error>
fn reduce( &self, mappings: &[MappedValue<Self::MappedKey<'_>, <Self::View as View>::Value>], rereduce: bool ) -> Result<<Self::View as View>::Value, Error>
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