pub struct Filter(/* private fields */);
Expand description
A Firestore query filter.
https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1#filter
§Examples
use firestore_structured_query::{FieldPath, Filter};
use googleapis_tonic_google_firestore_v1::google::firestore::v1::{structured_query, value::ValueType, Value};
let filter1: Filter = FieldPath::raw("field1").less_than(Value {
value_type: Some(ValueType::IntegerValue(1)),
})?;
let filter2: Filter = FieldPath::raw("field2").less_than_or_equal(Value {
value_type: Some(ValueType::IntegerValue(2)),
})?;
let filter3 = Filter::and([filter1.clone(), filter2.clone()]);
let filter4 = Filter::or([filter1.clone(), filter2.clone()]);
assert_eq!(
structured_query::Filter::from(filter3),
structured_query::Filter {
filter_type: Some(structured_query::filter::FilterType::CompositeFilter(
structured_query::CompositeFilter {
op: structured_query::composite_filter::Operator::And as i32,
filters: vec![
structured_query::Filter::from(filter1.clone()),
structured_query::Filter::from(filter2.clone())
],
},
)),
}
);
assert_eq!(
structured_query::Filter::from(filter4),
structured_query::Filter {
filter_type: Some(structured_query::filter::FilterType::CompositeFilter(
structured_query::CompositeFilter {
op: structured_query::composite_filter::Operator::Or as i32,
filters: vec![
structured_query::Filter::from(filter1),
structured_query::Filter::from(filter2)
],
},
)),
}
);
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn and<I>(filters: I) -> Selfwhere
I: IntoIterator<Item = Self>,
pub fn and<I>(filters: I) -> Selfwhere
I: IntoIterator<Item = Self>,
Creates a new CompositeFilter
with the And
operator.
https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1#compositefilter https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1#google.firestore.v1.StructuredQuery.CompositeFilter.Operator.ENUM_VALUES.google.firestore.v1.StructuredQuery.CompositeFilter.Operator.AND
§Examples
use firestore_structured_query::{FieldPath, Filter};
use googleapis_tonic_google_firestore_v1::google::firestore::v1::{structured_query, value::ValueType, Value};
let filter1 = FieldPath::raw("field1").less_than(Value {
value_type: Some(ValueType::IntegerValue(1)),
})?;
let filter2 = FieldPath::raw("field2").less_than_or_equal(Value {
value_type: Some(ValueType::IntegerValue(2)),
})?;
let filter3 = Filter::and([filter1.clone(), filter2.clone()]);
assert_eq!(
structured_query::Filter::from(filter3),
structured_query::Filter {
filter_type: Some(structured_query::filter::FilterType::CompositeFilter(
structured_query::CompositeFilter {
op: structured_query::composite_filter::Operator::And as i32,
filters: vec![
structured_query::Filter::from(filter1),
structured_query::Filter::from(filter2)
],
},
)),
}
);
Sourcepub fn or<I>(filters: I) -> Selfwhere
I: IntoIterator<Item = Self>,
pub fn or<I>(filters: I) -> Selfwhere
I: IntoIterator<Item = Self>,
Creates a new CompositeFilter
with the Or
operator.
https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1#compositefilter https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1#google.firestore.v1.StructuredQuery.CompositeFilter.Operator.ENUM_VALUES.google.firestore.v1.StructuredQuery.CompositeFilter.Operator.OR
§Examples
use firestore_structured_query::{FieldPath, Filter};
use googleapis_tonic_google_firestore_v1::google::firestore::v1::{structured_query, value::ValueType, Value};
let filter1 = FieldPath::raw("field1").less_than(Value {
value_type: Some(ValueType::IntegerValue(1)),
})?;
let filter2 = FieldPath::raw("field2").less_than_or_equal(Value {
value_type: Some(ValueType::IntegerValue(2)),
})?;
let filter3 = Filter::or([filter1.clone(), filter2.clone()]);
assert_eq!(
structured_query::Filter::from(filter3),
structured_query::Filter {
filter_type: Some(structured_query::filter::FilterType::CompositeFilter(
structured_query::CompositeFilter {
op: structured_query::composite_filter::Operator::Or as i32,
filters: vec![
structured_query::Filter::from(filter1),
structured_query::Filter::from(filter2)
],
},
)),
}
);
Trait Implementations§
impl StructuralPartialEq for Filter
Auto Trait Implementations§
impl Freeze for Filter
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnwindSafe for Filter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request