Trait pliantdb_core::schema::view::View [−][src]
pub trait View: Send + Sync + Debug + 'static { type Collection: Collection; type Key: Key + 'static; type Value: Serialize + for<'de> Deserialize<'de> + Send + Sync; fn version(&self) -> u64; fn name(&self) -> Result<Name, InvalidNameError>; fn map(&self, document: &Document<'_>) -> MapResult<Self::Key, Self::Value>; fn unique(&self) -> bool { ... } fn view_name(&self) -> Result<ViewName, InvalidNameError> { ... } fn reduce(
&self,
mappings: &[MappedValue<Self::Key, Self::Value>],
rereduce: bool
) -> Result<Self::Value, Error> { ... } }
Expand description
A map/reduce powered indexing and aggregation schema.
Inspired by CouchDB
’s view
system
This implementation is under active development, our own docs explaining our implementation will be written as things are solidified. The guide has an overview.
Associated Types
type Collection: Collection
type Collection: Collection
The collection this view belongs to
Required methods
The version of the view. Changing this value will cause indexes to be rebuilt.
fn name(&self) -> Result<Name, InvalidNameError>
fn name(&self) -> Result<Name, InvalidNameError>
The name of the view. Must be unique per collection.
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.
fn view_name(&self) -> Result<ViewName, InvalidNameError>
fn view_name(&self) -> Result<ViewName, InvalidNameError>
The namespaced name of the view.
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