use crate::{DbBackend, Statement, StatementBuilder};
pub trait QueryTrait {
type QueryStatement: StatementBuilder;
fn query(&mut self) -> &mut Self::QueryStatement;
fn as_query(&self) -> &Self::QueryStatement;
fn into_query(self) -> Self::QueryStatement;
fn build(&self, db_backend: DbBackend) -> Statement {
StatementBuilder::build(self.as_query(), &db_backend)
}
fn apply_if<T, F>(self, val: Option<T>, if_some: F) -> Self
where
Self: Sized,
F: FnOnce(Self, T) -> Self,
{
if let Some(val) = val {
if_some(self, val)
} else {
self
}
}
}