pub struct LambdaWrapper<T: GetFields> { /* private fields */ }Expand description
Lambda wrapper for compile-time safe column references.
This wrapper uses struct field accessor functions instead of string column names, providing compile-time safety for column references.
Implementations§
Source§impl<T: GetFields> LambdaWrapper<T>
impl<T: GetFields> LambdaWrapper<T>
Sourcepub fn from_wrapper(wrapper: Wrapper) -> Self
pub fn from_wrapper(wrapper: Wrapper) -> Self
Create a lambda wrapper from an existing Wrapper.
This allows wrapping an already-configured Wrapper to add lambda-style
type-safe conditions on top.
§Parameters
wrapper: The existingWrapperto wrap.
Sourcepub fn into_wrapper(self) -> Wrapper
pub fn into_wrapper(self) -> Wrapper
Consume the lambda wrapper and return the underlying Wrapper.
Useful when you need to pass the built wrapper to a query executor.
Sourcepub fn wrapper(&self) -> &Wrapper
pub fn wrapper(&self) -> &Wrapper
Get a reference to the underlying Wrapper.
Useful for inspecting the current state of the query without consuming the lambda wrapper.
Sourcepub fn ne<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
pub fn ne<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
Add a not equals (!=) condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.value: The value to compare against.
Sourcepub fn gt<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
pub fn gt<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
Add a greater than (>) condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.value: The value to compare against.
Sourcepub fn ge<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
pub fn ge<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
Add a greater than or equals (>=) condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.value: The value to compare against.
Sourcepub fn lt<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
pub fn lt<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
Add a less than (<) condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.value: The value to compare against.
Sourcepub fn le<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
pub fn le<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
Add a less than or equals (<=) condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.value: The value to compare against.
Sourcepub fn like<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
pub fn like<V: IntoAkitaValue>(self, field: fn(&T) -> String, value: V) -> Self
Add a LIKE condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.value: The pattern to match against (supports%and_wildcards).
Sourcepub fn not_like<V: IntoAkitaValue>(
self,
field: fn(&T) -> String,
value: V,
) -> Self
pub fn not_like<V: IntoAkitaValue>( self, field: fn(&T) -> String, value: V, ) -> Self
Add a NOT LIKE condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.value: The pattern to exclude (supports%and_wildcards).
Sourcepub fn is_null(self, field: fn(&T) -> String) -> Self
pub fn is_null(self, field: fn(&T) -> String) -> Self
Add an IS NULL condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.
Sourcepub fn is_not_null(self, field: fn(&T) -> String) -> Self
pub fn is_not_null(self, field: fn(&T) -> String) -> Self
Add an IS NOT NULL condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.
Sourcepub fn in<V: IntoAkitaValue, I: IntoIterator<Item = V>>(
self,
field: fn(&T) -> String,
values: I,
) -> Self
pub fn in<V: IntoAkitaValue, I: IntoIterator<Item = V>>( self, field: fn(&T) -> String, values: I, ) -> Self
Add an IN condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.values: An iterable of values to match against.
Sourcepub fn not_in<V: IntoAkitaValue, I: IntoIterator<Item = V>>(
self,
field: fn(&T) -> String,
values: I,
) -> Self
pub fn not_in<V: IntoAkitaValue, I: IntoIterator<Item = V>>( self, field: fn(&T) -> String, values: I, ) -> Self
Add a NOT IN condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.values: An iterable of values to exclude.
Sourcepub fn between<V: IntoAkitaValue>(
self,
field: fn(&T) -> String,
start: V,
end: V,
) -> Self
pub fn between<V: IntoAkitaValue>( self, field: fn(&T) -> String, start: V, end: V, ) -> Self
Add a BETWEEN condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.start: The lower bound value (inclusive).end: The upper bound value (inclusive).
Sourcepub fn not_between<V: IntoAkitaValue>(
self,
field: fn(&T) -> String,
start: V,
end: V,
) -> Self
pub fn not_between<V: IntoAkitaValue>( self, field: fn(&T) -> String, start: V, end: V, ) -> Self
Add a NOT BETWEEN condition using a field accessor.
§Parameters
field: A function that extracts the column name from the entity struct.start: The lower bound value (inclusive).end: The upper bound value (inclusive).
Sourcepub fn and<F>(self, func: F) -> Self
pub fn and<F>(self, func: F) -> Self
Add an AND group of conditions.
The closure receives a fresh LambdaWrapper<T> and should return it with
the desired conditions applied. The resulting conditions are wrapped in
parentheses and joined with AND.
§Parameters
func: A closure that configures the inner lambda wrapper.
Sourcepub fn or<F>(self, func: F) -> Self
pub fn or<F>(self, func: F) -> Self
Add an OR group of conditions.
The closure receives a fresh LambdaWrapper<T> and should return it with
the desired conditions applied. The resulting conditions are wrapped in
parentheses and joined with OR.
§Parameters
func: A closure that configures the inner lambda wrapper.
Sourcepub fn or_direct(self) -> Self
pub fn or_direct(self) -> Self
Add a direct OR separator between the previous and next condition.
Unlike or(), this does not create a parenthesized group.
It simply inserts OR at the current position in the WHERE clause.
Sourcepub fn order_by_asc(self, field: fn(&T) -> String) -> Self
pub fn order_by_asc(self, field: fn(&T) -> String) -> Self
Add an ORDER BY ASC clause using a field accessor.
§Parameters
field: A function that extracts the column name to sort by.
Sourcepub fn order_by_desc(self, field: fn(&T) -> String) -> Self
pub fn order_by_desc(self, field: fn(&T) -> String) -> Self
Add an ORDER BY DESC clause using a field accessor.
§Parameters
field: A function that extracts the column name to sort by.
Sourcepub fn offset(self, offset: u64) -> Self
pub fn offset(self, offset: u64) -> Self
Set the number of rows to skip before returning results.
§Parameters
offset: The number of rows to skip.
Sourcepub fn page(self, page: u64, size: u64) -> Self
pub fn page(self, page: u64, size: u64) -> Self
Set pagination by page number and page size.
This is a convenience method that computes the appropriate LIMIT and
OFFSET from the given page number and size.
§Parameters
page: The 1-based page number.size: The number of rows per page.