Trait mongod::Update [−][src]
pub trait Update { fn new() -> Self; fn into_document(self) -> Result<Document, Error>; }
Expand description
Used to mark a type as an update for use in queries.
Examples
Creating an update for user.
use mongod::bson::Document; use mongod::{Error, Update}; #[derive(Default)] pub struct UserUpdate { pub name: Option<String>, } impl Update for UserUpdate { fn new() -> Self { UserUpdate::default() } fn into_document(self) -> Result<Document, Error> { let mut doc = Document::new(); if let Some(value) = self.name { doc.insert("name", value); } Ok(doc) } }
Required methods
fn into_document(self) -> Result<Document, Error>
fn into_document(self) -> Result<Document, Error>
Converts a Filter
into a BSON Document
.