mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-02 11:13:29 +00:00
AND search params together properly (#2430)
This commit is contained in:
parent
312524a860
commit
334254abe6
|
@ -6,6 +6,7 @@ use crate::{
|
|||
util::{unsafe_streamed_query, BatchedStream},
|
||||
};
|
||||
|
||||
use prisma_client_rust::Operator;
|
||||
use sd_core_indexer_rules::seed::no_hidden;
|
||||
use sd_core_indexer_rules::IndexerRule;
|
||||
use sd_core_prisma_helpers::{file_path_with_object, object_with_file_paths};
|
||||
|
@ -195,7 +196,7 @@ pub fn mount() -> AlphaRouter<Ctx> {
|
|||
fp
|
||||
};
|
||||
|
||||
let mut query = db.file_path().find_many(params);
|
||||
let mut query = db.file_path().find_many(andify(params));
|
||||
|
||||
if let Some(take) = take {
|
||||
query = query.take(take as i64);
|
||||
|
@ -306,7 +307,7 @@ pub fn mount() -> AlphaRouter<Ctx> {
|
|||
obj.push(prisma::object::file_paths::some(fp));
|
||||
}
|
||||
|
||||
obj
|
||||
andify(obj)
|
||||
})
|
||||
.take(take as i64);
|
||||
|
||||
|
@ -412,3 +413,13 @@ async fn merge_filters(
|
|||
|
||||
Ok((fp, obj))
|
||||
}
|
||||
|
||||
/// PCR 0.6.x's AND does { AND: [{ ...}] } instead of { AND: [{ ... }, { ... }, { ... }] },
|
||||
/// this works around it.
|
||||
fn andify<T: From<Operator<T>>>(params: Vec<T>) -> Vec<T> {
|
||||
params.into_iter().fold(vec![], |mut params, param| {
|
||||
params.push(param);
|
||||
|
||||
vec![prisma_client_rust::operator::and(params).into()]
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue