entity/ent/query/
filter.rs1use crate::{Id, Predicate, TypedPredicate};
2
3#[derive(Clone, Debug)]
6pub enum Filter {
7 Id(TypedPredicate<Id>),
9
10 Type(TypedPredicate<String>),
12
13 Created(TypedPredicate<u64>),
15
16 LastUpdated(TypedPredicate<u64>),
18
19 Field(String, Predicate),
21
22 Edge(String, Box<Filter>),
25
26 IntoEdge(String),
28}
29
30impl Filter {
31 pub fn where_id<P: Into<TypedPredicate<Id>>>(p: P) -> Self {
32 Self::Id(p.into())
33 }
34
35 pub fn where_type<P: Into<TypedPredicate<String>>>(p: P) -> Self {
36 Self::Type(p.into())
37 }
38
39 pub fn where_created<P: Into<TypedPredicate<u64>>>(p: P) -> Self {
40 Self::Created(p.into())
41 }
42
43 pub fn where_last_updated<P: Into<TypedPredicate<u64>>>(p: P) -> Self {
44 Self::LastUpdated(p.into())
45 }
46
47 pub fn where_field<S: Into<String>, P: Into<Predicate>>(name: S, p: P) -> Self {
48 Self::Field(name.into(), p.into())
49 }
50
51 pub fn where_edge<S: Into<String>, F: Into<Filter>>(name: S, filter: F) -> Self {
52 Self::Edge(name.into(), Box::new(filter.into()))
53 }
54
55 pub fn where_into_edge<S: Into<String>>(name: S) -> Self {
56 Self::IntoEdge(name.into())
57 }
58}