work
This commit is contained in:
parent
dccdf7fffe
commit
897d23f917
1 changed files with 16 additions and 3 deletions
19
src/item.rs
19
src/item.rs
|
@ -471,13 +471,26 @@ impl InventoryCache {
|
|||
.client()
|
||||
.database("cdb")
|
||||
.collection::<mongodb::bson::Document>("cache")
|
||||
.find_one_and_update(doc! { "_id": "inventory"}, update, options)
|
||||
.find_one_and_update_with_session(doc! { "_id": "inventory"}, update, options, ses)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub async fn remove(uuid: &str) {
|
||||
// todo : remove from cache
|
||||
pub async fn remove(uuid: &str, ses: &mut ClientSession) {
|
||||
let update = doc! { "$pull": { "transactions": uuid}};
|
||||
|
||||
let options = mongodb::options::FindOneAndUpdateOptions::builder()
|
||||
.upsert(true)
|
||||
.return_document(mongodb::options::ReturnDocument::After)
|
||||
.build();
|
||||
|
||||
let result = ses
|
||||
.client()
|
||||
.database("cdb")
|
||||
.collection::<mongodb::bson::Document>("cache")
|
||||
.find_one_and_update_with_session(doc! { "_id": "inventory"}, update, options, ses)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue