This commit is contained in:
JMARyA 2024-05-03 13:40:06 +02:00
parent dccdf7fffe
commit 897d23f917
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -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();
}
}