pub struct Sort<T> {
pub by: T,
pub direction: ListDirection,
}Expand description
Structure to sort entities on a specific field when listing from database
Sort enum is used to specify the sorting order and the field to sort the entities by when listing them using list_for_filter
generated by EsRepo. It is generated automatically for all fields which have list_by option. It encapsulates two fields,
first is by to specify the field name, second is direction which takes ListDirection
§Example
ⓘ
let result = users.list_for_filter(
// `UsersFilter::WithName` generated by `EsRepo` using `list_for` option on `name`
UsersFilter::WithName("Murphy".to_string()),
Sort {
// `UsersSortBy::Id` and `UsersSortBy::CreatedAt` are created by default,
// other columns need `list_by` to sort by
by: UsersSortBy::Id,
direction: ListDirection::Descending,
},
PaginatedQueryArgs {
first: 10,
after: Default::default(),
},
)
.await?;Fields§
§by: T§direction: ListDirectionTrait Implementations§
impl<T: Copy> Copy for Sort<T>
Auto Trait Implementations§
impl<T> Freeze for Sort<T>where
T: Freeze,
impl<T> RefUnwindSafe for Sort<T>where
T: RefUnwindSafe,
impl<T> Send for Sort<T>where
T: Send,
impl<T> Sync for Sort<T>where
T: Sync,
impl<T> Unpin for Sort<T>where
T: Unpin,
impl<T> UnwindSafe for Sort<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more