inventory
This commit is contained in:
parent
72586df67f
commit
0be7fff77d
6 changed files with 49 additions and 9 deletions
|
@ -55,7 +55,9 @@ impl Variant {
|
|||
"variant": &self.variant
|
||||
};
|
||||
|
||||
let result = Transaction::find_partial(filter, json!({}), None).await.unwrap();
|
||||
let result = Transaction::find_partial(filter, json!({}), None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut ret = Vec::new();
|
||||
|
||||
|
@ -66,6 +68,16 @@ impl Variant {
|
|||
ret
|
||||
}
|
||||
|
||||
pub async fn inventory(&self) -> Vec<Transaction> {
|
||||
let filter = doc! {
|
||||
"item": &self.item,
|
||||
"variant": &self.variant,
|
||||
"consumed": { "$exists": false }
|
||||
};
|
||||
|
||||
Transaction::find(filter, None).await.unwrap()
|
||||
}
|
||||
|
||||
pub async fn demand_log(&self) -> Vec<String> {
|
||||
let filter = doc! {
|
||||
"item": &self.item,
|
||||
|
@ -73,7 +85,9 @@ impl Variant {
|
|||
"consumed": { "$exists": true }
|
||||
};
|
||||
|
||||
let result = Transaction::find_partial(filter, json!({}), None).await.unwrap();
|
||||
let result = Transaction::find_partial(filter, json!({}), None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut ret = Vec::new();
|
||||
|
||||
|
@ -89,7 +103,9 @@ impl Variant {
|
|||
let mut t = Transaction::get(uuid).await?;
|
||||
t.update(&json!({
|
||||
"consumed": Consumed{ destination: destination.to_string(), price }
|
||||
})).await.ok()?;
|
||||
}))
|
||||
.await
|
||||
.ok()?;
|
||||
|
||||
Some(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue