fix
This commit is contained in:
parent
ad96e2938d
commit
c68f871f4d
3 changed files with 29 additions and 26 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use mongod::{vec_to_api, ToAPI};
|
||||
use mongod::{reference_of, vec_to_api, Model, ToAPI};
|
||||
use rocket::{get, State};
|
||||
use serde_json::json;
|
||||
|
||||
|
@ -109,6 +109,9 @@ pub async fn location_inventory(
|
|||
) -> FallibleApiResponse {
|
||||
check_auth!(t, c);
|
||||
|
||||
let location =
|
||||
reference_of!(Location, location).ok_or_else(|| api_error("No such location"))?;
|
||||
|
||||
if let Some("true" | "yes" | "1") = recursive {
|
||||
return Ok(json!(
|
||||
vec_to_api(&Transaction::in_location_recursive(location).await).await
|
||||
|
|
|
@ -113,12 +113,12 @@ impl Transaction {
|
|||
false
|
||||
}
|
||||
|
||||
pub async fn in_location(l: &str) -> Vec<Self> {
|
||||
pub async fn in_location(l: Reference) -> Vec<Self> {
|
||||
Self::find(doc! { "location": l}, None, None).await.unwrap()
|
||||
}
|
||||
|
||||
pub async fn in_location_recursive(l: &str) -> Vec<Self> {
|
||||
let locations = Location::find(doc! { "parent": l}, None, None)
|
||||
pub async fn in_location_recursive(l: Reference) -> Vec<Self> {
|
||||
let locations = Location::find(doc! { "parent": &l}, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
let mut transactions = Self::find(doc! { "location": l}, None, None).await.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue