feat: Make the QueryBuilder with_criteria use FilterFunc

This commit is contained in:
Clément Renault 2019-02-03 10:55:16 +01:00
parent d46fa4b215
commit 7a6166d229
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE

View File

@ -53,15 +53,15 @@ where D: Deref<Target=DB>
pub fn new(view: &'a DatabaseView<D>) -> Result<Self, Box<Error>> { pub fn new(view: &'a DatabaseView<D>) -> Result<Self, Box<Error>> {
QueryBuilder::with_criteria(view, Criteria::default()) QueryBuilder::with_criteria(view, Criteria::default())
} }
pub fn with_criteria(view: &'a DatabaseView<D>, criteria: Criteria) -> Result<Self, Box<Error>> {
Ok(QueryBuilder { view, criteria, filter: None })
}
} }
impl<'a, D, FI> QueryBuilder<'a, D, FI> impl<'a, D, FI> QueryBuilder<'a, D, FI>
where D: Deref<Target=DB>, where D: Deref<Target=DB>,
{ {
pub fn with_criteria(view: &'a DatabaseView<D>, criteria: Criteria) -> Result<Self, Box<Error>> {
Ok(QueryBuilder { view, criteria, filter: None })
}
pub fn with_filter<F>(self, function: F) -> QueryBuilder<'a, D, F> pub fn with_filter<F>(self, function: F) -> QueryBuilder<'a, D, F>
where F: Fn(DocumentId, &DatabaseView<D>) -> bool, where F: Fn(DocumentId, &DatabaseView<D>) -> bool,
{ {