View Source Appwrite.Utils.Query (appwrite v0.1.9)

A helper module to generate query strings for Appwrite filters.

This module provides functions to construct queries for filtering, sorting, and limiting resources in an Appwrite database.

Each function returns a JSON string representation of the query.

Summary

Functions

Filter resources where attribute is between the start and end values (inclusive).

Filter resources where attribute contains the specified value(s).

Return results after the specified document ID.

Return results before the specified document ID.

Filter resources where attribute ends with the value.

Filter resources where attribute is equal to the value.

Filter resources where attribute is greater than the value.

Filter resources where attribute is greater than or equal to the value.

Filter resources where attribute is not null.

Filter resources where attribute is null.

Filter resources where attribute is less than the value.

Filter resources where attribute is less than or equal to the value.

Limit the number of results returned.

Combine multiple queries using logical AND.

Combine multiple queries using logical OR.

Create a query with the given method, attribute, and values.

Filter resources where attribute is not equal to the value.

Skip the first offset number of results.

Sort results by attribute ascending.

Sort results by attribute descending.

Filter resources by searching an attribute for a value.

Specify which attributes should be returned by the API call.

Filter resources where attribute starts with the value.

Types

attributes_types()

@type attributes_types() :: String.t() | [String.t()]

query_types()

@type query_types() :: query_types_single() | query_types_list()

query_types_list()

@type query_types_list() :: [String.t() | number() | boolean() | map()]

query_types_single()

@type query_types_single() :: String.t() | number() | boolean()

Functions

between(attribute, start_value, end_value)

Filter resources where attribute is between the start and end values (inclusive).

contains(attribute, value)

@spec contains(String.t(), String.t() | [String.t()]) :: String.t()

Filter resources where attribute contains the specified value(s).

cursor_after(document_id)

@spec cursor_after(String.t()) :: String.t()

Return results after the specified document ID.

cursor_before(document_id)

@spec cursor_before(String.t()) :: String.t()

Return results before the specified document ID.

ends_with(attribute, value)

@spec ends_with(String.t(), String.t()) :: String.t()

Filter resources where attribute ends with the value.

equal(attribute, value)

@spec equal(String.t(), query_types()) :: String.t()

Filter resources where attribute is equal to the value.

greater_than(attribute, value)

@spec greater_than(String.t(), query_types()) :: String.t()

Filter resources where attribute is greater than the value.

greater_than_equal(attribute, value)

@spec greater_than_equal(String.t(), query_types()) :: String.t()

Filter resources where attribute is greater than or equal to the value.

is_not_null(attribute)

@spec is_not_null(String.t()) :: String.t()

Filter resources where attribute is not null.

is_null(attribute)

@spec is_null(String.t()) :: String.t()

Filter resources where attribute is null.

less_than(attribute, value)

@spec less_than(String.t(), query_types()) :: String.t()

Filter resources where attribute is less than the value.

less_than_equal(attribute, value)

@spec less_than_equal(String.t(), query_types()) :: String.t()

Filter resources where attribute is less than or equal to the value.

limit(limit)

@spec limit(non_neg_integer()) :: String.t()

Limit the number of results returned.

logical_and(queries)

@spec logical_and([String.t()]) :: String.t()

Combine multiple queries using logical AND.

logical_or(queries)

@spec logical_or([String.t()]) :: String.t()

Combine multiple queries using logical OR.

new(method, attribute \\ nil, values \\ nil)

@spec new(String.t(), attributes_types() | nil, query_types() | nil) :: String.t()

Create a query with the given method, attribute, and values.

Examples

iex> Appwrite.Query.new("equal", "name", "John")
"{"method":"equal","attribute":"name","values":["John"]}"

not_equal(attribute, value)

@spec not_equal(String.t(), query_types()) :: String.t()

Filter resources where attribute is not equal to the value.

offset(offset)

@spec offset(non_neg_integer()) :: String.t()

Skip the first offset number of results.

order_asc(attribute)

@spec order_asc(String.t()) :: String.t()

Sort results by attribute ascending.

order_desc(attribute)

@spec order_desc(String.t()) :: String.t()

Sort results by attribute descending.

search(attribute, value)

@spec search(String.t(), String.t()) :: String.t()

Filter resources by searching an attribute for a value.

select(attributes)

@spec select([String.t()]) :: String.t()

Specify which attributes should be returned by the API call.

starts_with(attribute, value)

@spec starts_with(String.t(), String.t()) :: String.t()

Filter resources where attribute starts with the value.