Functions
The following functions are available globally.
-
Returns a
Query
that is theor
of the passed in queries.Declaration
Swift
public func or<T>(queries: [Query<T>]) -> QueryConstraint where T : ParseObject
Parameters
queries
The list of queries to or together.
Return Value
An instance of
QueryConstraint
‘s that are theor
of the passed in queries. -
Returns a
Query
that is thenor
of the passed in queries.Declaration
Swift
public func nor<T>(queries: [Query<T>]) -> QueryConstraint where T : ParseObject
Parameters
queries
The list of queries to
or
together.Return Value
An instance of
QueryConstraint
‘s that are thenor
of the passed in queries. -
Constructs a Query that is the AND of the passed in queries. For example:
var compoundQueryConstraints = and(query1, query2, query3)
will create a compoundQuery that is an and of the query1, query2, and query3.
Declaration
Swift
public func and<T>(queries: [Query<T>]) -> QueryConstraint where T : ParseObject
Parameters
queries
The list of queries to AND.
Return Value
The query that is the AND of the passed in queries.
-
Add a constraint that requires that a key’s value matches a
Query
constraint.Declaration
Swift
public func == <T>(key: String, value: Query<T>) -> QueryConstraint where T : ParseObject
Parameters
key
The key that the value is stored in.
query
The query the value should match.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint that requires that a key’s value do not match a
Query
constraint.Declaration
Swift
public func != <T>(key: String, query: Query<T>) -> QueryConstraint where T : ParseObject
Parameters
key
The key that the value is stored in.
query
The query the value should not match.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Adds a constraint that requires that a key’s value matches a value in another key in objects returned by a sub query.
Declaration
Swift
public func matchesKeyInQuery<T>(key: String, queryKey: String, query: Query<T>) -> QueryConstraint where T : ParseObject
Parameters
key
The key that the value is stored.
queryKey
The key in objects in the returned by the sub query whose value should match.
query
The query to run.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Adds a constraint that requires that a key’s value not match a value in another key in objects returned by a sub query.
Declaration
Swift
public func doesNotMatchKeyInQuery<T>(key: String, queryKey: String, query: Query<T>) -> QueryConstraint where T : ParseObject
Parameters
key
The key that the value is stored.
queryKey
The key in objects returned by the sub query whose value should match.
query
The query to run.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s object to be contained in the provided array.
Declaration
Swift
public func containedIn<T>(key: String, array: [T]) -> QueryConstraint where T : Encodable
Parameters
key
The key to be constrained.
array
The possible values for the key’s object.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s object not be contained in the provided array.
Declaration
Swift
public func notContainedIn<T>(key: String, array: [T]) -> QueryConstraint where T : Encodable
Parameters
key
The key to be constrained.
array
The list of values the key’s object should not be.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s array contains every element of the provided array.
Declaration
Swift
public func containsAll<T>(key: String, array: [T]) -> QueryConstraint where T : Encodable
Parameters
key
The key to be constrained.
array
The possible values for the key’s object.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s object to be contained by the provided array. Get objects where all array elements match.
Declaration
Swift
public func containedBy<T>(key: String, array: [T]) -> QueryConstraint where T : Encodable
Parameters
key
The key to be constrained.
array
The possible values for the key’s object.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s time is related to a specified time. E.g. “3 days ago”.
Declaration
Swift
public func relative(key: String, comparator: QueryConstraint.Comparator, time: String) -> QueryConstraint
Parameters
key
The key to be constrained. Should be a Date field.
comparator
How the relative time should be compared. Currently only supports the $lt, $lte, $gt, and $gte operators.
time
The reference time, e.g. “12 days ago”.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s coordinates (specified via
ParseGeoPoint
) be near a reference point. Distance is calculated based on angular distance on a sphere. Results will be sorted by distance from reference point.Declaration
Swift
public func near(key: String, geoPoint: ParseGeoPoint) -> QueryConstraint
Parameters
key
The key to be constrained.
geoPoint
The reference point represented as a
ParseGeoPoint
.Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s coordinates (specified via
ParseGeoPoint
) be near a reference point and within the maximum distance specified (in radians). Distance is calculated based on angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point.Declaration
Swift
public func withinRadians(key: String, geoPoint: ParseGeoPoint, distance: Double, sorted: Bool = true) -> [QueryConstraint]
Parameters
key
The key to be constrained.
geoPoint
The reference point as a
ParseGeoPoint
.distance
Maximum distance in radians.
sorted
true
if results should be sorted by distance ascending,false
is no sorting is required. Defaults to true.Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s coordinates (specified via
ParseGeoPoint
) be near a reference point and within the maximum distance specified (in miles). Distance is calculated based on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.Declaration
Swift
public func withinMiles(key: String, geoPoint: ParseGeoPoint, distance: Double, sorted: Bool = true) -> [QueryConstraint]
Parameters
key
The key to be constrained.
geoPoint
The reference point represented as a
ParseGeoPoint
.distance
Maximum distance in miles.
sorted
true
if results should be sorted by distance ascending,false
is no sorting is required. Defaults to true.Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s coordinates (specified via
ParseGeoPoint
) be near a reference point and within the maximum distance specified (in kilometers). Distance is calculated based on a spherical coordinate system. Results will be sorted by distance (nearest to farthest) from the reference point.Declaration
Swift
public func withinKilometers(key: String, geoPoint: ParseGeoPoint, distance: Double, sorted: Bool = true) -> [QueryConstraint]
Parameters
key
The key to be constrained.
geoPoint
The reference point represented as a
ParseGeoPoint
.distance
Maximum distance in kilometers.
sorted
true
if results should be sorted by distance ascending,false
is no sorting is required. Defaults to true.Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s coordinates (specified via
ParseGeoPoint
) be contained within a given rectangular geographic bounding box.Declaration
Swift
public func withinGeoBox(key: String, fromSouthWest southwest: ParseGeoPoint, toNortheast northeast: ParseGeoPoint) -> QueryConstraint
Parameters
key
The key to be constrained.
fromSouthWest
The lower-left inclusive corner of the box.
toNortheast
The upper-right inclusive corner of the box.
Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s coordinates be contained within and on the bounds of a given polygon Supports closed and open (last point is connected to first) paths. (Requires [email protected])
Polygon must have at least 3 points.
Declaration
Swift
public func withinPolygon(key: String, points: [ParseGeoPoint]) -> QueryConstraint
Parameters
key
The key to be constrained.
points
The polygon points as an Array of
ParseGeoPoint
‘s.Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint to the query that requires a particular key’s coordinates that contains a
ParseGeoPoint
(Requires [email protected])Declaration
Swift
public func polygonContains(key: String, point: ParseGeoPoint) -> QueryConstraint
Parameters
key
The key to be constrained.
point
The point the polygon contains
ParseGeoPoint
.Return Value
The same instance of
QueryConstraint
as the receiver. -
Add a constraint for finding string values that contain a provided string using Full Text Search.
Declaration
Swift
public func matchesText(key: String, text: String) -> QueryConstraint
Parameters
key
The key to be constrained.
text
The substring that the value must contain.
Return Value
The same instance of
Query
as the receiver. -
Add a regular expression constraint for finding string values that match the provided regular expression.
Warning
This may be slow for large datasets.Declaration
Swift
public func matchesRegex(key: String, regex: String) -> QueryConstraint
Parameters
key
The key that the string to match is stored in.
regex
The regular expression pattern to match.
Return Value
The same instance of
Query
as the receiver. -
Add a regular expression constraint for finding string values that match the provided regular expression.
Warning
This may be slow for large datasets.i
- Case insensitive searchm
- Search across multiple lines of input
Declaration
Swift
public func matchesRegex(key: String, regex: String, modifiers: String) -> QueryConstraint
Parameters
key
The key that the string to match is stored in.
regex
The regular expression pattern to match.
modifiers
Any of the following supported PCRE modifiers:
Return Value
The same instance of
Query
as the receiver. -
Add a constraint for finding string values that contain a provided substring.
Warning
This will be slow for large datasets.Declaration
Swift
public func containsString(key: String, substring: String) -> QueryConstraint
Parameters
key
The key that the string to match is stored in.
substring
The substring that the value must contain.
Return Value
The same instance of
Query
as the receiver. -
Add a constraint for finding string values that start with a provided prefix. This will use smart indexing, so it will be fast for large datasets.
Declaration
Swift
public func hasPrefix(key: String, prefix: String) -> QueryConstraint
Parameters
key
The key that the string to match is stored in.
prefix
The substring that the value must start with.
Return Value
The same instance of
Query
as the receiver. -
Add a constraint for finding string values that end with a provided suffix.
Warning
This will be slow for large datasets.Declaration
Swift
public func hasSuffix(key: String, suffix: String) -> QueryConstraint
Parameters
key
The key that the string to match is stored in.
suffix
The substring that the value must end with.
Return Value
The same instance of
Query
as the receiver. -
Add a constraint that requires a particular key exists.
Declaration
Swift
public func exists(key: String) -> QueryConstraint
Parameters
key
The key that should exist.
Return Value
The same instance of
Query
as the receiver. -
Add a constraint that requires a key not exist.
Declaration
Swift
public func doesNotExist(key: String) -> QueryConstraint
Parameters
key
The key that should not exist.
Return Value
The same instance of
Query
as the receiver. -
Add a constraint that requires a key is related.
Declaration
Swift
public func related<T>(key: String, object: Pointer<T>) -> QueryConstraint where T : ParseObject
Parameters
key
The key that should be related.
object
The object that should be related.
Return Value
The same instance of
Query
as the receiver.