FilterBuilder

Struct FilterBuilder 

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

Builder for constructing document filter expressions.

This struct provides methods for comparing document fields with values to create filter conditions.

§Examples

// Combine multiple filter conditions
db.query("products")
    .filter(|f| {
        f.gte("price", 10.0) &&
        f.lte("price", 50.0) &&
        f.contains("name", "widget")
    })
    .collect()
    .await?;

Implementations§

Source§

impl<'a, 'b> FilterBuilder<'a, 'b>

Source

pub fn new(doc: &'b Document) -> Self

Create a new filter builder for the given document

Source

pub fn eq<T: Into<Value>>(&self, field: &str, value: T) -> bool

Check if a field equals a value

§Examples
.filter(|f| f.eq("status", "active"))
Source

pub fn gt<T: Into<Value>>(&self, field: &str, value: T) -> bool

Check if a field is greater than a value

§Examples
.filter(|f| f.gt("age", 21))
Source

pub fn gte<T: Into<Value>>(&self, field: &str, value: T) -> bool

Check if a field is greater than or equal to a value

§Examples
.filter(|f| f.gte("age", 21))
Source

pub fn lt<T: Into<Value>>(&self, field: &str, value: T) -> bool

Check if a field is less than a value

§Examples
.filter(|f| f.lt("age", 65))
Source

pub fn lte<T: Into<Value>>(&self, field: &str, value: T) -> bool

Check if a field is less than or equal to a value

§Examples
.filter(|f| f.lte("age", 65))
Source

pub fn contains(&self, field: &str, value: &str) -> bool

Check if a field contains a value

§Examples
.filter(|f| f.contains("name", "widget"))
Source

pub fn in_values<T: Into<Value> + Clone>( &self, field: &str, values: &[T], ) -> bool

Check if a field is in a list of values

§Examples
.filter(|f| f.in_values("status", &["active", "inactive"]))
Source

pub fn between<T: Into<Value> + Clone>( &self, field: &str, min: T, max: T, ) -> bool

Check if a field is between two values (inclusive)

§Examples
.filter(|f| f.between("age", 18, 65))
Source

pub fn exists(&self, field: &str) -> bool

Check if a field exists and is not null

§Examples
.filter(|f| f.exists("email"))
Source

pub fn is_null(&self, field: &str) -> bool

Check if a field doesn’t exist or is null

§Examples
.filter(|f| f.is_null("email"))
Source

pub fn starts_with(&self, field: &str, prefix: &str) -> bool

Check if a field starts with a prefix

§Examples
.filter(|f| f.starts_with("name", "John"))
Source

pub fn ends_with(&self, field: &str, suffix: &str) -> bool

Check if a field ends with a suffix

§Examples
.filter(|f| f.ends_with("name", "son"))
Source

pub fn array_contains(&self, field: &str, value: impl Into<Value>) -> bool

Check if a field is in an array

§Examples
.filter(|f| f.array_contains("status", "active"))
Source

pub fn array_len_eq(&self, field: &str, len: usize) -> bool

Check if an array has a specific length

§Examples
.filter(|f| f.array_len_eq("status", 2))
Source

pub fn get_nested_value(&self, path: &str) -> Option<&Value>

Access a nested field using dot notation

§Examples
.filter(|f| f.get_nested_value("user.address.city") == Some(&Value::String("New York")))
Source

pub fn nested_eq<T: Into<Value>>(&self, path: &str, value: T) -> bool

Check if a nested field equals a value

§Examples
.filter(|f| f.nested_eq("user.address.city", "New York"))
Source

pub fn matches_regex(&self, field: &str, pattern: &str) -> bool

Check if a field matches a regular expression

§Examples
.filter(|f| f.matches_regex("email", r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"))

Auto Trait Implementations§

§

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

§

impl<'a, 'b> RefUnwindSafe for FilterBuilder<'a, 'b>

§

impl<'a, 'b> Send for FilterBuilder<'a, 'b>

§

impl<'a, 'b> Sync for FilterBuilder<'a, 'b>

§

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

§

impl<'a, 'b> UnwindSafe for FilterBuilder<'a, 'b>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.