Trait couch_rs::document::TypedCouchDocument
source · pub trait TypedCouchDocument: DeserializeOwned + Serialize + Sized {
// Required methods
fn get_id(&self) -> Cow<'_, str>;
fn get_rev(&self) -> Cow<'_, str>;
fn set_rev(&mut self, rev: &str);
fn set_id(&mut self, id: &str);
fn merge_ids(&mut self, other: &Self);
}
Expand description
Trait to deal with typed CouchDB
documents.
For types implementing this trait, the _id and _rev fields on the json data sent/received to/from couchdb are automatically handled by this crate, using get_id
and get_rev
to get the values (before sending data to couchdb) and set_id
and set_rev
to set them (after receiving data from couchdb).
Note, when reading documents from couchdb directly, if whichever field name is used to store the revision is different from “_rev” (e.g. “my_rev
”), the value will always be “the last value of _rev” as updating “_rev is handled by couchdb, not this crate. This should be transparent to users of this crate
because set_rev
will be called before returning the document to the user, so the user will always see the correct value.
Required Methods§
Object Safety§
Implementations on Foreign Types§
source§impl TypedCouchDocument for Value
impl TypedCouchDocument for Value
Allows dealing with _id and _rev fields in untyped (Value) documents