pub struct Query { /* private fields */ }Expand description
A query type for models.
Implementations§
Source§impl Query
impl Query
Sourcepub fn from_entry(key: impl Into<String>, value: impl Into<JsonValue>) -> Self
pub fn from_entry(key: impl Into<String>, value: impl Into<JsonValue>) -> Self
Creates a new instance with the entry.
Sourcepub fn read_map(&mut self, data: &Map) -> Validation
pub fn read_map(&mut self, data: &Map) -> Validation
Updates the query using the json object and returns the validation result.
Sourcepub fn set_fields(&mut self, fields: Vec<String>)
pub fn set_fields(&mut self, fields: Vec<String>)
Sets the fields.
Sourcepub fn allow_fields(&mut self, fields: &[&str])
pub fn allow_fields(&mut self, fields: &[&str])
Retains the projection fields in the allow list. If the projection fields are empty, it will be set to the list.
Sourcepub fn deny_fields(&mut self, fields: &[&str])
pub fn deny_fields(&mut self, fields: &[&str])
Removes the projection fields in the deny list.
Sourcepub fn add_field_alias(
&mut self,
expr: impl Into<String>,
alias: impl Into<String>,
)
pub fn add_field_alias( &mut self, expr: impl Into<String>, alias: impl Into<String>, )
Adds a projection field with the alias.
Sourcepub fn add_filter(
&mut self,
key: impl Into<String>,
value: impl Into<JsonValue>,
)
pub fn add_filter( &mut self, key: impl Into<String>, value: impl Into<JsonValue>, )
Adds a key-value pair to the query filters.
Sourcepub fn append_filters(&mut self, filters: &mut Map)
pub fn append_filters(&mut self, filters: &mut Map)
Moves all elements from the filters into self.
Sourcepub fn remove_filter(&mut self, key: &str) -> Option<JsonValue>
pub fn remove_filter(&mut self, key: &str) -> Option<JsonValue>
Removes a query filter with the key.
Sourcepub fn set_extra_flag(
&mut self,
key: impl Into<String>,
value: impl Into<JsonValue>,
)
pub fn set_extra_flag( &mut self, key: impl Into<String>, value: impl Into<JsonValue>, )
Sets the extra flag.
Sourcepub fn append_extra_flags(&mut self, flags: &mut Map)
pub fn append_extra_flags(&mut self, flags: &mut Map)
Appends the extra flags.
Sourcepub fn set_order(&mut self, sort_order: Vec<QueryOrder>)
pub fn set_order(&mut self, sort_order: Vec<QueryOrder>)
Sets the sort order.
Sourcepub fn order_by(&mut self, field: impl Into<SharedString>, descending: bool)
pub fn order_by(&mut self, field: impl Into<SharedString>, descending: bool)
Adds a query order.
Sourcepub fn order_by_with_nulls(
&mut self,
field: impl Into<SharedString>,
descending: bool,
nulls_first: bool,
)
pub fn order_by_with_nulls( &mut self, field: impl Into<SharedString>, descending: bool, nulls_first: bool, )
Adds a query order with an extra flag to indicate whether the nulls appear first or last.
Sourcepub fn order_asc(&mut self, field: impl Into<SharedString>)
pub fn order_asc(&mut self, field: impl Into<SharedString>)
Adds a query order with an ascending order.
Sourcepub fn order_desc(&mut self, field: impl Into<SharedString>)
pub fn order_desc(&mut self, field: impl Into<SharedString>)
Adds a query order with an descending order.
Sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Sets the query offset.
Sourcepub fn disable_limit(&mut self)
pub fn disable_limit(&mut self)
Disables the query limit.
Sourcepub fn sort_order(&self) -> &[QueryOrder]
pub fn sort_order(&self) -> &[QueryOrder]
Returns a reference to the sort order.
Sourcepub fn populate_enabled(&self) -> bool
pub fn populate_enabled(&self) -> bool
Returns true if the populate flag has been enabled.
Sourcepub fn translate_enabled(&self) -> bool
pub fn translate_enabled(&self) -> bool
Returns true if the translate flag has been enabled.
Sourcepub fn show_deleted(&self) -> bool
pub fn show_deleted(&self) -> bool
Returns true if the show_deleted flag has been enabled.
Sourcepub fn validate_only(&self) -> bool
pub fn validate_only(&self) -> bool
Returns true if the validate_only flag has been enabled.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Query
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnwindSafe for Query
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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