Query

public struct Query<T> : Encodable, Equatable where T : ParseObject
extension Query: Queryable
extension Query: CustomDebugStringConvertible
extension Query: CustomStringConvertible

The Query class defines a query that is used to query for ParseObjects.

  • An enum that determines the order to sort the results based on a given key.

    See more

    Declaration

    Swift

    public enum Order : Encodable, Equatable

    Parameters

    key

    The key to order by.

  • Create an instance with a variadic amount constraints.

    Declaration

    Swift

    public init(_ constraints: QueryConstraint...)

    Parameters

    constraints

    A variadic amount of zero or more QueryConstraint‘s.

  • Create an instance with an array of constraints.

    Declaration

    Swift

    public init(_ constraints: [QueryConstraint])

    Parameters

    constraints

    An array of QueryConstraint‘s.

  • Declaration

    Swift

    public static func == (lhs: Query<T>, rhs: Query<T>) -> Bool
  • Add any amount of variadic constraints.

    Declaration

    Swift

    public func `where`(_ constraints: QueryConstraint...) -> Query<T>

    Parameters

    constraints

    A variadic amount of zero or more QueryConstraint‘s.

  • Add an array of variadic constraints.

    Declaration

    Swift

    public func `where`(_ constraints: [QueryConstraint]) -> Query<T>

    Parameters

    constraints

    An array of zero or more QueryConstraint‘s.

  • A limit on the number of objects to return. The default limit is 100, with a maximum of 1000 results being returned at a time.

    Note

    If you are calling find with limit = 1, you may find it easier to use first instead.

    Declaration

    Swift

    public func limit(_ value: Int) -> Query<T>

    Parameters

    value

    n number of results to limit to.

  • The number of objects to skip before returning any. This is useful for pagination. Default is to skip zero results.

    Declaration

    Swift

    public func skip(_ value: Int) -> Query<T>

    Parameters

    value

    n number of results to skip.

  • Adds a hint to force index selection.

    Declaration

    Swift

    public func hint<U>(_ value: U) -> Query<T> where U : Encodable

    Parameters

    value

    String or Object of index that should be used when executing query.

  • Changes the read preference that the backend will use when performing the query to the database.

    Declaration

    Swift

    public func readPreference(_ readPreference: String?,
                               includeReadPreference: String? = nil,
                               subqueryReadPreference: String? = nil) -> Query<T>

    Parameters

    readPreference

    The read preference for the main query.

    includeReadPreference

    The read preference for the queries to include pointers.

    subqueryReadPreference

    The read preference for the sub queries.

  • Make the query include ParseObjects that have a reference stored at the provided keys. If this is called multiple times, then all of the keys specified in each of the calls will be included.

    Declaration

    Swift

    public func include(_ keys: String...) -> Query<T>

    Parameters

    keys

    A variadic list of keys to load child ParseObjects for.

  • Make the query include ParseObjects that have a reference stored at the provided keys. If this is called multiple times, then all of the keys specified in each of the calls will be included.

    Declaration

    Swift

    public func include(_ keys: [String]) -> Query<T>

    Parameters

    keys

    An array of keys to load child ParseObjects for.

  • Includes all nested ParseObjects one level deep.

    Warning

    Requires Parse Server 3.0.0+.

    Declaration

    Swift

    public func includeAll() -> Query<T>
  • Exclude specific keys for a ParseObject. If this is called multiple times, then all of the keys specified in each of the calls will be excluded.

    Warning

    Requires Parse Server 5.0.0+.

    Declaration

    Swift

    public func exclude(_ keys: String...) -> Query<T>

    Parameters

    keys

    A variadic list of keys include in the result.

  • Exclude specific keys for a ParseObject. If this is called multiple times, then all of the keys specified in each of the calls will be excluded.

    Warning

    Requires Parse Server 5.0.0+.

    Declaration

    Swift

    public func exclude(_ keys: [String]) -> Query<T>

    Parameters

    keys

    An array of keys to exclude in the result.

  • Make the query restrict the fields of the returned ParseObjects to include only the provided keys. If this is called multiple times, then all of the keys specified in each of the calls will be included.

    Warning

    Requires Parse Server 5.0.0+.

    Declaration

    Swift

    public func select(_ keys: String...) -> Query<T>

    Parameters

    keys

    A variadic list of keys include in the result.

  • Make the query restrict the fields of the returned ParseObjects to include only the provided keys. If this is called multiple times, then all of the keys specified in each of the calls will be included.

    Warning

    Requires Parse Server 5.0.0+.

    Declaration

    Swift

    public func select(_ keys: [String]) -> Query<T>

    Parameters

    keys

    An array of keys to include in the result.

  • An enum that determines the order to sort the results based on a given key.

    Declaration

    Swift

    public func order(_ keys: [Order]?) -> Query<T>

    Parameters

    keys

    An array of keys to order by.

  • A variadic list of fields to receive when receiving a ParseLiveQuery.

    Suppose the ParseObject Player contains three fields name, id and age. If you are only interested in the change of the name field, you can set query.fields to “name”. In this situation, when the change of a Player ParseObject fulfills the subscription, only the name field will be sent to the clients instead of the full Player ParseObject. If this is called multiple times, then all of the keys specified in each of the calls will be received.

    Warning

    This is only for ParseLiveQuery.

    Declaration

    Swift

    public func fields(_ keys: String...) -> Query<T>

    Parameters

    keys

    A variadic list of fields to receive back instead of the whole ParseObject.

  • A list of fields to receive when receiving a ParseLiveQuery.

    Suppose the ParseObject Player contains three fields name, id and age. If you are only interested in the change of the name field, you can set query.fields to “name”. In this situation, when the change of a Player ParseObject fulfills the subscription, only the name field will be sent to the clients instead of the full Player ParseObject. If this is called multiple times, then all of the keys specified in each of the calls will be received.

    Warning

    This is only for ParseLiveQuery.

    Declaration

    Swift

    public func fields(_ keys: [String]) -> Query<T>

    Parameters

    keys

    An array of fields to receive back instead of the whole ParseObject.

  • The className of the ParseObject to query.

    Declaration

    Swift

    public var className: String { get }
  • The className of the ParseObject to query.

    Declaration

    Swift

    public static var className: String { get }

ParseLiveQuery - Subscribe

  • Registers the query for live updates, using the default subscription handler, and the default ParseLiveQuery client. Suitable for ObjectObserved as the subscription can be used as a SwiftUI publisher. Meaning it can serve indepedently as a ViewModel in MVVM.

    Declaration

    Swift

    var subscribe: Subscription<ResultType>? { get }
  • Registers the query for live updates, using the default subscription handler, and a specific ParseLiveQuery client. Suitable for ObjectObserved as the subscription can be used as a SwiftUI publisher. Meaning it can serve indepedently as a ViewModel in MVVM.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func subscribe(_ client: ParseLiveQuery) throws -> Subscription<ResultType>

    Parameters

    client

    A specific client.

    Return Value

    The subscription that has just been registered.

  • Registers a query for live updates, using a custom subscription handler.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    static func subscribe<T>(_ handler: T) throws -> T where T : QuerySubscribable

    Parameters

    handler

    A custom subscription handler.

    Return Value

    Your subscription handler, for easy chaining.

  • Registers a query for live updates, using a custom subscription handler.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    static func subscribe<T>(_ handler: T, client: ParseLiveQuery) throws -> T where T : QuerySubscribable

    Parameters

    handler

    A custom subscription handler.

    client

    A specific client.

    Return Value

    Your subscription handler, for easy chaining.

  • Registers the query for live updates, using the default subscription handler, and the default ParseLiveQuery client.

    Declaration

    Swift

    var subscribeCallback: SubscriptionCallback<ResultType>? { get }
  • Registers the query for live updates, using the default subscription handler, and a specific ParseLiveQuery client.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func subscribeCallback(_ client: ParseLiveQuery) throws -> SubscriptionCallback<ResultType>

    Parameters

    client

    A specific client.

    Return Value

    The subscription that has just been registered.

ParseLiveQuery - Unsubscribe

ParseLiveQuery - Update

  • Updates an existing subscription with a new query on the default ParseLiveQuery client. Upon completing the registration, the subscribe handler will be called with the new query.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func update<T>(_ handler: T) throws where T : QuerySubscribable

    Parameters

    handler

    The specific handler to update.

  • Updates an existing subscription with a new query on a specific ParseLiveQuery client. Upon completing the registration, the subscribe handler will be called with the new query.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func update<T>(_ handler: T, client: ParseLiveQuery) throws where T : QuerySubscribable

    Parameters

    handler

    The specific handler to update.

    client

    A specific client.

Async/Await

  • find(options:) Asynchronous

    Finds objects asynchronously.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func find(options: API.Options = []) async throws -> [ResultType]

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

  • Query plan information for finding objects asynchronously.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func findExplain<U: Decodable>(usingMongoDB: Bool = false,
                                   options: API.Options = []) async throws -> [U]

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

  • Retrieves asynchronously a complete list of ParseObject‘s that satisfy this query.

    Throws

    An error of type ParseError.

    Warning

    The items are processed in an unspecified order. The query may not have any sort order, and may not use limit or skip.

    Declaration

    Swift

    func findAll(batchLimit: Int? = nil,
                 options: API.Options = []) async throws -> [ResultType]

    Parameters

    batchLimit

    The maximum number of objects to send in each batch. If the items to be batched.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

  • first(options:) Asynchronous

    Gets an object asynchronously.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func first(options: API.Options = []) async throws -> ResultType

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    The first ParseObject.

  • Query plan information for getting an object asynchronously.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func firstExplain<U: Decodable>(usingMongoDB: Bool = false,
                                    options: API.Options = []) async throws -> U

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

  • count(options:) Asynchronous

    Count objects asynchronously.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func count(options: API.Options = []) async throws -> Int

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    The count of ParseObject‘s.

  • Query plan information for counting objects asynchronously.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func countExplain<U: Decodable>(usingMongoDB: Bool = false,
                                    options: API.Options = []) async throws -> [U]

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

  • withCount(options:) Asynchronous

    Finds objects asynchronously and returns a tuple of the results which include the total number of objects satisfying this query, despite limits/skip. Might be useful for pagination.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func withCount(options: API.Options = []) async throws -> ([ResultType], Int)

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    The count of ParseObject‘s.

  • Query plan information for withCount objects asynchronously.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func withCountExplain<U: Decodable>(usingMongoDB: Bool = false,
                                        options: API.Options = []) async throws -> [U]

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

  • aggregate(_:options:) Asynchronous

    Executes an aggregate query asynchronously.

    Requires

    .useMasterKey has to be available.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func aggregate(_ pipeline: [[String: Encodable]],
                   options: API.Options = []) async throws -> [ResultType]

    Parameters

    pipeline

    A pipeline of stages to process query.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

  • Query plan information for executing an aggregate query asynchronously.

    Requires

    .useMasterKey has to be available.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func aggregateExplain<U: Decodable>(_ pipeline: [[String: Encodable]],
                                        usingMongoDB: Bool = false,
                                        options: API.Options = []) async throws -> [U]

    Parameters

    pipeline

    A pipeline of stages to process query.

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

  • distinct(_:options:) Asynchronous

    Executes a distinct query asynchronously and returns unique values when complete.

    Requires

    .useMasterKey has to be available.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func distinct(_ key: String,
                  options: API.Options = []) async throws -> [ResultType]

    Parameters

    key

    A field to find distinct values.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

  • Query plan information for executing a distinct query asynchronously and returns unique values when complete.

    Requires

    .useMasterKey has to be available.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func distinctExplain<U: Decodable>(_ key: String,
                                       usingMongoDB: Bool = false,
                                       options: API.Options = []) async throws -> [U]

    Parameters

    key

    A field to find distinct values.

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An array of ParseObjects.

Combine

  • Finds objects asynchronously and publishes when complete.

    Declaration

    Swift

    func findPublisher(options: API.Options = []) -> Future<[ResultType], ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Query plan information for finding objects asynchronously and publishes when complete.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func findExplainPublisher<U: Decodable>(usingMongoDB: Bool = false,
                                            options: API.Options = []) -> Future<[U], ParseError>

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Retrieves asynchronously a complete list of ParseObject‘s that satisfy this query and publishes when complete.

    Warning

    The items are processed in an unspecified order. The query may not have any sort order, and may not use limit or skip.

    Declaration

    Swift

    func findAllPublisher(batchLimit: Int? = nil,
                          options: API.Options = []) -> Future<[ResultType], ParseError>

    Parameters

    batchLimit

    The maximum number of objects to send in each batch. If the items to be batched.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Gets an object asynchronously and publishes when complete.

    Declaration

    Swift

    func firstPublisher(options: API.Options = []) -> Future<ResultType, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Query plan information for getting an object asynchronously and publishes when complete.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func firstExplainPublisher<U: Decodable>(usingMongoDB: Bool = false,
                                             options: API.Options = []) -> Future<U, ParseError>

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Count objects asynchronously and publishes when complete.

    Declaration

    Swift

    func countPublisher(options: API.Options = []) -> Future<Int, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Query plan information for counting objects asynchronously and publishes when complete.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func countExplainPublisher<U: Decodable>(usingMongoDB: Bool = false,
                                             options: API.Options = []) -> Future<[U], ParseError>

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Finds objects asynchronously and returns a tuple of the results which include the total number of objects satisfying this query, despite limits/skip. Might be useful for pagination. Publishes when complete.

    Declaration

    Swift

    func withCountPublisher(options: API.Options = []) -> Future<([ResultType], Int), ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Query plan information for counting objects asynchronously and publishes when complete.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func withCountExplainPublisher<U: Decodable>(usingMongoDB: Bool = false,
                                                 options: API.Options = []) -> Future<[U], ParseError>

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Executes an aggregate query asynchronously and publishes when complete.

    Requires

    .useMasterKey has to be available.

    Declaration

    Swift

    func aggregatePublisher(_ pipeline: [[String: Encodable]],
                            options: API.Options = []) -> Future<[ResultType], ParseError>

    Parameters

    pipeline

    A pipeline of stages to process query.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Query plan information for executing an aggregate query asynchronously and publishes when complete.

    Requires

    .useMasterKey has to be available.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func aggregateExplainPublisher<U: Decodable>(_ pipeline: [[String: Encodable]],
                                                 usingMongoDB: Bool = false,
                                                 options: API.Options = []) -> Future<[U], ParseError>

    Parameters

    pipeline

    A pipeline of stages to process query.

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Executes a distinct query asynchronously and publishes unique values when complete.

    Requires

    .useMasterKey has to be available.

    Declaration

    Swift

    func distinctPublisher(_ key: String,
                           options: API.Options = []) -> Future<[ResultType], ParseError>

    Parameters

    key

    A field to find distinct values.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Query plan information for executing a distinct query asynchronously and publishes unique values when complete.

    Requires

    .useMasterKey has to be available.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    func distinctExplainPublisher<U: Decodable>(_ key: String,
                                                usingMongoDB: Bool = false,
                                                options: API.Options = []) -> Future<[U], ParseError>

    Parameters

    key

    A field to find distinct values.

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Queryable

  • Finds objects synchronously based on the constructed query and sets an error if there was one.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    public func find(options: API.Options = []) throws -> [ResultType]

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns an array of ParseObjects that were found.

  • Query plan information for finding objects synchronously based on the constructed query and sets an error if there was one.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func findExplain<U: Decodable>(usingMongoDB: Bool = false,
                                          options: API.Options = []) throws -> [U]

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns a response of Decodable type.

  • Finds objects asynchronously and returns a completion block with the results.

    Declaration

    Swift

    public func find(options: API.Options = [],
                     callbackQueue: DispatchQueue = .main,
                     completion: @escaping (Result<[ResultType], ParseError>) -> Void)

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<[ResultType], ParseError>).

  • Query plan information for finding objects asynchronously and returns a completion block with the results.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func findExplain<U: Decodable>(usingMongoDB: Bool = false,
                                          options: API.Options = [],
                                          callbackQueue: DispatchQueue = .main,
                                          completion: @escaping (Result<[U], ParseError>) -> Void)

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<[Decodable], ParseError>).

  • Retrieves asynchronously a complete list of ParseObject‘s that satisfy this query.

    Declaration

    Swift

    public func findAll(batchLimit limit: Int? = nil,
                        options: API.Options = [],
                        callbackQueue: DispatchQueue = .main,
                        completion: @escaping (Result<[ResultType], ParseError>) -> Void)

    Parameters

    batchLimit

    The maximum number of objects to send in each batch. If the items to be batched. is greater than the batchLimit, the objects will be sent to the server in waves up to the batchLimit. Defaults to 50.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<[Decodable], ParseError>).

    Warning

    The items are processed in an unspecified order. The query may not have any sort order, and may not use limit or skip.

  • Gets an object synchronously based on the constructed query and sets an error if any occurred.

    Warning

    This method mutates the query. It will reset the limit to 1.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    public func first(options: API.Options = []) throws -> ResultType

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns a ParseObject.

  • Query plan information for getting an object synchronously based on the constructed query and sets an error if any occurred.

    Warning

    This method mutates the query. It will reset the limit to 1.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func firstExplain<U: Decodable>(usingMongoDB: Bool = false,
                                           options: API.Options = []) throws -> U

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns a response of Decodable type.

  • Gets an object asynchronously and calls the given block with the result.

    Warning

    This method mutates the query. It will reset the limit to 1.

    Declaration

    Swift

    public func first(options: API.Options = [],
                      callbackQueue: DispatchQueue = .main,
                      completion: @escaping (Result<ResultType, ParseError>) -> Void)

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<ParseObject, ParseError>).

  • Query plan information for getting an object asynchronously and returns a completion block with the result.

    Warning

    This method mutates the query. It will reset the limit to 1.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func firstExplain<U: Decodable>(usingMongoDB: Bool = false,
                                           options: API.Options = [],
                                           callbackQueue: DispatchQueue = .main,
                                           completion: @escaping (Result<U, ParseError>) -> Void)

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Decodable, ParseError>).

  • Counts objects synchronously based on the constructed query and sets an error if there was one.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    public func count(options: API.Options = []) throws -> Int

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns the number of ParseObjects that match the query, or -1 if there is an error.

  • Query plan information for counting objects synchronously based on the constructed query and sets an error if there was one.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func countExplain<U: Decodable>(usingMongoDB: Bool = false,
                                           options: API.Options = []) throws -> [U]

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns a response of Decodable type.

  • Counts objects asynchronously and returns a completion block with the count.

    Declaration

    Swift

    public func count(options: API.Options = [],
                      callbackQueue: DispatchQueue = .main,
                      completion: @escaping (Result<Int, ParseError>) -> Void)

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Int, ParseError>)

  • Query plan information for counting objects asynchronously and returns a completion block with the count.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func countExplain<U: Decodable>(usingMongoDB: Bool = false,
                                           options: API.Options = [],
                                           callbackQueue: DispatchQueue = .main,
                                           completion: @escaping (Result<[U], ParseError>) -> Void)

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Decodable, ParseError>).

  • Finds objects asynchronously and returns a completion block with the results which include the total number of objects satisfying this query, despite limits/skip. Might be useful for pagination.

    Declaration

    Swift

    public func withCount(options: API.Options = [],
                          callbackQueue: DispatchQueue = .main,
                          completion: @escaping (Result<([ResultType], Int), ParseError>) -> Void)

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<([ResultType], Int), ParseError>)

  • Query plan information for withCount objects asynchronously and a completion block with the results.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for mongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func withCountExplain<U: Decodable>(usingMongoDB: Bool = false,
                                               options: API.Options = [],
                                               callbackQueue: DispatchQueue = .main,
                                               completion: @escaping (Result<[U], ParseError>) -> Void)

    Parameters

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Decodable, ParseError>).

  • Executes an aggregate query synchronously.

    Requires

    .useMasterKey has to be available.

    Throws

    An error of type ParseError.

    Warning

    This hasn’t been tested thoroughly.

    Declaration

    Swift

    public func aggregate(_ pipeline: [[String: Encodable]],
                          options: API.Options = []) throws -> [ResultType]

    Parameters

    pipeline

    A pipeline of stages to process query.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns the ParseObjects that match the query.

  • Executes an aggregate query asynchronously.

    Requires

    .useMasterKey has to be available.

    Warning

    This hasn’t been tested thoroughly.

    Declaration

    Swift

    public func aggregate(_ pipeline: [[String: Encodable]],
                          options: API.Options = [],
                          callbackQueue: DispatchQueue = .main,
                          completion: @escaping (Result<[ResultType], ParseError>) -> Void)

    Parameters

    pipeline

    A pipeline of stages to process query.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<[ParseObject], ParseError>).

  • Query plan information for executing an aggregate query synchronously.

    Requires

    .useMasterKey has to be available.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func aggregateExplain<U: Decodable>(_ pipeline: [[String: Encodable]],
                                               usingMongoDB: Bool = false,
                                               options: API.Options = []) throws -> [U]

    Parameters

    pipeline

    A pipeline of stages to process query.

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns the ParseObjects that match the query.

  • Query plan information for executing an aggregate query asynchronously.

    Requires

    .useMasterKey has to be available.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func aggregateExplain<U: Decodable>(_ pipeline: [[String: Encodable]],
                                               usingMongoDB: Bool = false,
                                               options: API.Options = [],
                                               callbackQueue: DispatchQueue = .main,
                                               completion: @escaping (Result<[U], ParseError>) -> Void)

    Parameters

    pipeline

    A pipeline of stages to process query.

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<[ParseObject], ParseError>).

  • Executes an aggregate query synchronously and calls the given.

    Requires

    .useMasterKey has to be available.

    Throws

    An error of type ParseError.

    Warning

    This hasn’t been tested thoroughly.

    Declaration

    Swift

    public func distinct(_ key: String,
                         options: API.Options = []) throws -> [ResultType]

    Parameters

    key

    A field to find distinct values.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns the ParseObjects that match the query.

  • Executes a distinct query asynchronously and returns unique values.

    Requires

    .useMasterKey has to be available.

    Warning

    This hasn’t been tested thoroughly.

    Declaration

    Swift

    public func distinct(_ key: String,
                         options: API.Options = [],
                         callbackQueue: DispatchQueue = .main,
                         completion: @escaping (Result<[ResultType], ParseError>) -> Void)

    Parameters

    key

    A field to find distinct values.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<[ParseObject], ParseError>).

  • Query plan information for executing an aggregate query synchronously and calls the given.

    Requires

    .useMasterKey has to be available.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Throws

    An error of type ParseError.

    Warning

    This hasn’t been tested thoroughly.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func distinctExplain<U: Decodable>(_ key: String,
                                              usingMongoDB: Bool = false,
                                              options: API.Options = []) throws -> [U]

    Parameters

    key

    A field to find distinct values.

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns the ParseObjects that match the query.

  • Query plan information for executing a distinct query asynchronously and returns unique values.

    Requires

    .useMasterKey has to be available.

    Note

    An explain query will have many different underlying types. Since Swift is a strongly typed language, a developer should specify the type expected to be decoded which will be different for MongoDB and PostgreSQL. One way around this is to use a type-erased wrapper such as the AnyCodable package.

    Warning

    MongoDB’s explain does not conform to the traditional Parse Server response, so the usingMongoDB flag needs to be set for MongoDB users. See more here.

    Declaration

    Swift

    public func distinctExplain<U: Decodable>(_ key: String,
                                              usingMongoDB: Bool = false,
                                              options: API.Options = [],
                                              callbackQueue: DispatchQueue = .main,
                                              completion: @escaping (Result<[U], ParseError>) -> Void)

    Parameters

    key

    A field to find distinct values.

    usingMongoDB

    Set to true if your Parse Server uses MongoDB. Defaults to false.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<[Decodable], ParseError>).

CustomDebugStringConvertible

  • Declaration

    Swift

    public var debugDescription: String { get }

CustomStringConvertible

  • Declaration

    Swift

    public var description: String { get }

QueryViewModel

  • Creates a view model for this query. Suitable for ObjectObserved as the view model can be used as a SwiftUI publisher. Meaning it can serve indepedently as a ViewModel in MVVM.

    Declaration

    Swift

    var viewModel: QueryViewModel<ResultType> { get }
  • Creates a view model for this query. Suitable for ObjectObserved as the view model can be used as a SwiftUI publisher. Meaning it can serve indepedently as a ViewModel in MVVM.

    Declaration

    Swift

    static func viewModel(_ query: `Self`) -> QueryViewModel<ResultType>

    Parameters

    query

    Any query.

    Return Value

    The view model for this query.

Available where T: ParseObject & ParseQueryScorable

  • Method to sort the full text search by text score.

    Note

    Your ParseObject should conform to ParseQueryScorable to retrieve the weight/rank via the “score” property of your ParseObject.

    Declaration

    Swift

    public func sortByTextScore() -> Query<T>

    Parameters

    value

    String or Object of index that should be used when executing query.