pub struct ParseQuery { /* private fields */ }
Expand description
Represents a query to be performed against a Parse Server class.
Implementations§
Source§impl ParseQuery
impl ParseQuery
Sourcepub fn new(class_name: &str) -> Self
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.
Sourcepub fn class_name(&self) -> &str
pub fn class_name(&self) -> &str
Returns the class name this query targets.
Sourcepub fn uses_master_key(&self) -> bool
pub fn uses_master_key(&self) -> bool
Checks if this query is configured to use the master key.
Sourcepub fn set_master_key(&mut self, use_key: bool) -> &mut Self
pub fn set_master_key(&mut self, use_key: bool) -> &mut Self
Sets whether this query should be executed using the master key.
Sourcepub fn equal_to<V: Serialize>(&mut self, key: &str, value: V) -> &mut Self
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.
Sourcepub fn not_equal_to<V: Serialize>(&mut self, key: &str, value: V) -> &mut Self
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.
Sourcepub fn exists(&mut self, key: &str) -> &mut Self
pub fn exists(&mut self, key: &str) -> &mut Self
Adds a constraint to the query that a field must exist.
Sourcepub fn does_not_exist(&mut self, key: &str) -> &mut Self
pub fn does_not_exist(&mut self, key: &str) -> &mut Self
Adds a constraint to the query that a field must not exist.
Sourcepub fn greater_than<V: Serialize>(&mut self, key: &str, value: V) -> &mut Self
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.
Sourcepub fn greater_than_or_equal_to<V: Serialize>(
&mut self,
key: &str,
value: V,
) -> &mut Self
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.
Sourcepub fn less_than<V: Serialize>(&mut self, key: &str, value: V) -> &mut Self
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.
Sourcepub fn less_than_or_equal_to<V: Serialize>(
&mut self,
key: &str,
value: V,
) -> &mut Self
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.
Sourcepub fn contained_in<V: Serialize>(
&mut self,
key: &str,
values: Vec<V>,
) -> &mut Self
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.
Sourcepub fn not_contained_in<V: Serialize>(
&mut self,
key: &str,
values: Vec<V>,
) -> &mut Self
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.
Sourcepub fn contains_all<V: Serialize>(
&mut self,
key: &str,
values: Vec<V>,
) -> &mut Self
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).
Sourcepub fn starts_with(&mut self, key: &str, prefix: &str) -> &mut Self
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.
Sourcepub fn ends_with(&mut self, key: &str, suffix: &str) -> &mut Self
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.
Sourcepub fn contains(&mut self, key: &str, substring: &str) -> &mut Self
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.*
.
Sourcepub fn matches_regex(
&mut self,
key: &str,
regex_pattern: &str,
modifiers: Option<&str>,
) -> &mut Self
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.
Sourcepub fn search(
&mut self,
key: &str,
term: &str,
language: Option<&str>,
case_sensitive: Option<bool>,
diacritic_sensitive: Option<bool>,
) -> &mut Self
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.
Adds a constraint to the query that objects must be related to a given parent object through a specific relation field.
§Arguments
parent_object
- APointer
to the parent object.key_on_parent_object
- The name of the relation field on theparent_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”.
Sourcepub fn limit(&mut self, count: isize) -> &mut Self
pub fn limit(&mut self, count: isize) -> &mut Self
Sets the maximum number of results to return.
Sourcepub fn skip(&mut self, count: usize) -> &mut Self
pub fn skip(&mut self, count: usize) -> &mut Self
Sets the number of results to skip before returning.
Sourcepub fn order(&mut self, field_names: &str) -> &mut Self
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”
Sourcepub fn order_by_ascending(&mut self, key: &str) -> &mut Self
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.
Sourcepub fn order_by_descending(&mut self, key: &str) -> &mut Self
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.
Sourcepub fn add_ascending_order(&mut self, key: &str) -> &mut Self
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.
Sourcepub fn add_descending_order(&mut self, key: &str) -> &mut Self
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.
Sourcepub fn include(&mut self, keys_to_include: &[&str]) -> &mut Self
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.
Sourcepub fn select(&mut self, keys_to_select: &[&str]) -> &mut Self
pub fn select(&mut self, keys_to_select: &[&str]) -> &mut Self
Restricts the fields returned for all matching objects.
pub fn build_query_params(&self) -> Vec<(String, String)>
Sourcepub async fn find<T: DeserializeOwned + Send + Sync + 'static>(
&self,
client: &Parse,
) -> Result<Vec<T>, ParseError>
pub async fn find<T: DeserializeOwned + Send + Sync + 'static>( &self, client: &Parse, ) -> Result<Vec<T>, ParseError>
Retrieves a list of ParseObject
s that match this query.
Sourcepub async fn first<T: DeserializeOwned + Send + Sync + 'static>(
&self,
client: &Parse,
) -> Result<Option<T>, ParseError>
pub async fn first<T: DeserializeOwned + Send + Sync + 'static>( &self, client: &Parse, ) -> Result<Option<T>, ParseError>
Retrieves the first ParseObject
that matches this query.
Sourcepub async fn get<T: DeserializeOwned + Send + Sync + 'static>(
&self,
object_id: &str,
client: &Parse,
) -> Result<T, ParseError>
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.
Sourcepub async fn count(&self, client: &Parse) -> Result<u64, ParseError>
pub async fn count(&self, client: &Parse) -> Result<u64, ParseError>
Counts the number of objects that match this query.
Sourcepub async fn distinct<T: DeserializeOwned + Send + Sync + 'static>(
&self,
client: &Parse,
field: &str,
) -> Result<Vec<T>, ParseError>
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.
Sourcepub async fn aggregate<T: DeserializeOwned + Send + Sync + 'static>(
&self,
pipeline: Vec<Value>,
client: &Parse,
) -> Result<Vec<T>, ParseError>
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 ofserde_json::Value
representing the aggregation stages.client
- TheParse
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
impl Clone for ParseQuery
Source§fn clone(&self) -> ParseQuery
fn clone(&self) -> ParseQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more