macro_rules! update {
($($json:tt)+) => { ... };
}
Expand description
Construct a serde_json::Value
from a JSON literal
representing update value for find_and_update API.
use memquery::{doc, errors::Error, memdb::MemDb, query, update};
async fn play() -> Result<(), Error> {
let memdb = MemDb::new();
let coll = memdb.collection("TestCollection").await?;
coll.insert(doc!({ "name": "Tom", "age": 25 })).await?;
let docs_updated = coll
.find_and_update(
query!({ "name": "Tom" }),
update!({ "$set": { "name": "Roy", "age": 21, "email": "test@test.com" }}),
)
.await?;
Ok(())
}