Merge pull request #95 from Kerollmops/fix-querybuilder-with-criteria

Make the QueryBuilder with_criteria use FilterFunc
This commit is contained in:
Clément Renault 2019-02-03 11:24:17 +01:00 committed by GitHub
commit 8438e2202f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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,
{ {