Struct ParseQuery

Source
pub struct ParseQuery { /* private fields */ }
Expand description

Represents a query to be performed against a Parse Server class.

Implementations§

Source§

impl ParseQuery

Source

pub fn new(class_name: &str) -> Self

Creates a new ParseQuery for the specified class name.

§Arguments
  • class_name - The name of the Parse class to query.
Source

pub fn class_name(&self) -> &str

Returns the class name this query targets.

Source

pub fn uses_master_key(&self) -> bool

Checks if this query is configured to use the master key.

Source

pub fn set_master_key(&mut self, use_key: bool) -> &mut Self

Sets whether this query should be executed using the master key.

Source

pub fn equal_to<V: Serialize>(&mut self, key: &str, value: V) -> &mut Self

Adds a constraint to the query that a field must be equal to a specified value.

Source

pub fn not_equal_to<V: Serialize>(&mut self, key: &str, value: V) -> &mut Self

Adds a constraint to the query that a field must not be equal to a specified value.

Source

pub fn exists(&mut self, key: &str) -> &mut Self

Adds a constraint to the query that a field must exist.

Source

pub fn does_not_exist(&mut self, key: &str) -> &mut Self

Adds a constraint to the query that a field must not exist.

Source

pub fn greater_than<V: Serialize>(&mut self, key: &str, value: V) -> &mut Self

Adds a constraint for finding objects where a field’s value is greater than the provided value.

Source

pub fn greater_than_or_equal_to<V: Serialize>( &mut self, key: &str, value: V, ) -> &mut Self

Adds a constraint for finding objects where a field’s value is greater than or equal to the provided value.

Source

pub fn less_than<V: Serialize>(&mut self, key: &str, value: V) -> &mut Self

Adds a constraint for finding objects where a field’s value is less than the provided value.

Source

pub fn less_than_or_equal_to<V: Serialize>( &mut self, key: &str, value: V, ) -> &mut Self

Adds a constraint for finding objects where a field’s value is less than or equal to the provided value.

Source

pub fn contained_in<V: Serialize>( &mut self, key: &str, values: Vec<V>, ) -> &mut Self

Adds a constraint for finding objects where a field’s value is contained in the provided list of values.

Source

pub fn not_contained_in<V: Serialize>( &mut self, key: &str, values: Vec<V>, ) -> &mut Self

Adds a constraint for finding objects where a field’s value is not contained in the provided list of values.

Source

pub fn contains_all<V: Serialize>( &mut self, key: &str, values: Vec<V>, ) -> &mut Self

Adds a constraint for finding objects where a field contains all of the provided values (for array fields).

Source

pub fn starts_with(&mut self, key: &str, prefix: &str) -> &mut Self

Adds a constraint for finding objects where a string field starts with a given prefix.

Source

pub fn ends_with(&mut self, key: &str, suffix: &str) -> &mut Self

Adds a constraint for finding objects where a string field ends with a given suffix.

Source

pub fn contains(&mut self, key: &str, substring: &str) -> &mut Self

Adds a constraint for finding objects where a string field contains a given substring. This uses a regex .*substring.*.

Source

pub fn matches_regex( &mut self, key: &str, regex_pattern: &str, modifiers: Option<&str>, ) -> &mut Self

Adds a constraint for finding objects where a string field matches a given regex pattern. Modifiers can be ‘i’ for case-insensitive, ‘m’ for multiline, etc.

Source

pub fn search( &mut self, key: &str, term: &str, language: Option<&str>, case_sensitive: Option<bool>, diacritic_sensitive: Option<bool>, ) -> &mut Self

Adds a constraint for full-text search on a field. Requires a text index to be configured on the field in MongoDB.

§Arguments
  • key - The field to perform the text search on.
  • term - The search term.
  • language - Optional: The language for the search (e.g., “en”, “es”).
  • case_sensitive - Optional: Whether the search should be case-sensitive.
  • diacritic_sensitive - Optional: Whether the search should be diacritic-sensitive.
Source

pub fn related_to( &mut self, parent_object: &Pointer, key_on_parent_object: &str, ) -> &mut Self

Adds a constraint to the query that objects must be related to a given parent object through a specific relation field.

§Arguments
  • parent_object - A Pointer to the parent object.
  • key_on_parent_object - The name of the relation field on the parent_object.

Example: Querying for “Comment” objects related to a “Post” object via the “comments” relation field on “Post”:

// let post_pointer = Pointer::new("Post", "postId123");
// let mut comment_query = ParseQuery::new("Comment");
// comment_query.related_to(&post_pointer, "comments");

This will find all “Comment” objects that are part of the “comments” relation of the specified “Post”.

Source

pub fn limit(&mut self, count: isize) -> &mut Self

Sets the maximum number of results to return.

Source

pub fn skip(&mut self, count: usize) -> &mut Self

Sets the number of results to skip before returning.

Source

pub fn order(&mut self, field_names: &str) -> &mut Self

Sets the order of the results. Replaces any existing order. Takes a comma-separated string of field names. Prefix with ‘-’ for descending order. e.g., “score,-playerName”

Source

pub fn order_by_ascending(&mut self, key: &str) -> &mut Self

Sorts the results by a given key in ascending order. Replaces existing sort order.

Source

pub fn order_by_descending(&mut self, key: &str) -> &mut Self

Sorts the results by a given key in descending order. Replaces existing sort order.

Source

pub fn add_ascending_order(&mut self, key: &str) -> &mut Self

Adds a key to sort the results by in ascending order. Appends to existing sort order.

Source

pub fn add_descending_order(&mut self, key: &str) -> &mut Self

Adds a key to sort the results by in descending order. Appends to existing sort order.

Source

pub fn include(&mut self, keys_to_include: &[&str]) -> &mut Self

Includes nested ParseObjects for the given pointer key(s). The included field’s data will be fetched and returned with the main object.

Source

pub fn select(&mut self, keys_to_select: &[&str]) -> &mut Self

Restricts the fields returned for all matching objects.

Source

pub fn build_query_params(&self) -> Vec<(String, String)>

Source

pub async fn find<T: DeserializeOwned + Send + Sync + 'static>( &self, client: &Parse, ) -> Result<Vec<T>, ParseError>

Retrieves a list of ParseObjects that match this query.

Source

pub async fn first<T: DeserializeOwned + Send + Sync + 'static>( &self, client: &Parse, ) -> Result<Option<T>, ParseError>

Retrieves the first ParseObject that matches this query.

Source

pub async fn get<T: DeserializeOwned + Send + Sync + 'static>( &self, object_id: &str, client: &Parse, ) -> Result<T, ParseError>

Retrieves a specific ParseObject by its ID from the class associated with this query. Note: This method ignores other query constraints like equalTo, limit, etc., and directly fetches by ID.

Source

pub async fn count(&self, client: &Parse) -> Result<u64, ParseError>

Counts the number of objects that match this query.

Source

pub async fn distinct<T: DeserializeOwned + Send + Sync + 'static>( &self, client: &Parse, field: &str, ) -> Result<Vec<T>, ParseError>

Executes a distinct query for a specific field. Returns a vector of unique values for the given field that match the query conditions.

Source

pub async fn aggregate<T: DeserializeOwned + Send + Sync + 'static>( &self, pipeline: Vec<Value>, client: &Parse, ) -> Result<Vec<T>, ParseError>

Executes an aggregation query.

The pipeline is a series of data aggregation steps. Refer to MongoDB aggregation pipeline documentation. Each stage in the pipeline should be a serde_json::Value object. This operation typically requires the master key.

§Arguments
  • pipeline - A vector of serde_json::Value representing the aggregation stages.
  • client - The Parse to use for the request.
§Returns

A Result containing a Vec<T> of the deserialized results, or a ParseError.

Trait Implementations§

Source§

impl Clone for ParseQuery

Source§

fn clone(&self) -> ParseQuery

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParseQuery

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

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
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,