FilterBuilder

Struct FilterBuilder 

Source
pub struct FilterBuilder<'a> { /* private fields */ }
Expand description

A builder for constructing filters within a pool.

Provides ergonomic methods for building filter trees with minimal allocations.

Implementations§

Source§

impl<'a> FilterBuilder<'a>

Source

pub fn value<V: IntoPooledValue<'a>>(&self, v: V) -> PooledValue<'a>

Convert a value into a pooled value.

Source

pub fn none(&self) -> PooledFilter<'a>

Create an empty filter (matches everything).

Source

pub fn eq<V: IntoPooledValue<'a>>( &self, field: &str, value: V, ) -> PooledFilter<'a>

Create an equals filter.

§Examples
use prax_query::pool::FilterPool;

let pool = FilterPool::new();
let filter = pool.build(|b| b.eq("status", "active"));
Source

pub fn ne<V: IntoPooledValue<'a>>( &self, field: &str, value: V, ) -> PooledFilter<'a>

Create a not equals filter.

Source

pub fn lt<V: IntoPooledValue<'a>>( &self, field: &str, value: V, ) -> PooledFilter<'a>

Create a less than filter.

Source

pub fn lte<V: IntoPooledValue<'a>>( &self, field: &str, value: V, ) -> PooledFilter<'a>

Create a less than or equal filter.

Source

pub fn gt<V: IntoPooledValue<'a>>( &self, field: &str, value: V, ) -> PooledFilter<'a>

Create a greater than filter.

Source

pub fn gte<V: IntoPooledValue<'a>>( &self, field: &str, value: V, ) -> PooledFilter<'a>

Create a greater than or equal filter.

Source

pub fn is_in( &self, field: &str, values: Vec<PooledValue<'a>>, ) -> PooledFilter<'a>

Create an IN filter.

§Examples
use prax_query::pool::FilterPool;

let pool = FilterPool::new();
let filter = pool.build(|b| {
    b.is_in("status", vec![b.value("pending"), b.value("processing")])
});
Source

pub fn not_in( &self, field: &str, values: Vec<PooledValue<'a>>, ) -> PooledFilter<'a>

Create a NOT IN filter.

Source

pub fn contains<V: IntoPooledValue<'a>>( &self, field: &str, value: V, ) -> PooledFilter<'a>

Create a contains filter (LIKE %value%).

Source

pub fn starts_with<V: IntoPooledValue<'a>>( &self, field: &str, value: V, ) -> PooledFilter<'a>

Create a starts with filter (LIKE value%).

Source

pub fn ends_with<V: IntoPooledValue<'a>>( &self, field: &str, value: V, ) -> PooledFilter<'a>

Create an ends with filter (LIKE %value).

Source

pub fn is_null(&self, field: &str) -> PooledFilter<'a>

Create an IS NULL filter.

Source

pub fn is_not_null(&self, field: &str) -> PooledFilter<'a>

Create an IS NOT NULL filter.

Source

pub fn and(&self, filters: Vec<PooledFilter<'a>>) -> PooledFilter<'a>

Create an AND filter combining multiple filters.

§Examples
use prax_query::pool::FilterPool;

let pool = FilterPool::new();
let filter = pool.build(|b| {
    b.and(vec![
        b.eq("active", true),
        b.gt("score", 100),
        b.is_not_null("email"),
    ])
});
Source

pub fn or(&self, filters: Vec<PooledFilter<'a>>) -> PooledFilter<'a>

Create an OR filter combining multiple filters.

§Examples
use prax_query::pool::FilterPool;

let pool = FilterPool::new();
let filter = pool.build(|b| {
    b.or(vec![
        b.eq("role", "admin"),
        b.eq("role", "moderator"),
    ])
});
Source

pub fn not(&self, filter: PooledFilter<'a>) -> PooledFilter<'a>

Create a NOT filter.

§Examples
use prax_query::pool::FilterPool;

let pool = FilterPool::new();
let filter = pool.build(|b| b.not(b.eq("deleted", true)));

Auto Trait Implementations§

§

impl<'a> Freeze for FilterBuilder<'a>

§

impl<'a> !RefUnwindSafe for FilterBuilder<'a>

§

impl<'a> !Send for FilterBuilder<'a>

§

impl<'a> !Sync for FilterBuilder<'a>

§

impl<'a> Unpin for FilterBuilder<'a>

§

impl<'a> !UnwindSafe for FilterBuilder<'a>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more