FIRQuery


@interface FIRQuery : NSObject

A FIRQuery refers to a Query which you can read or listen to. You can also construct refined FIRQuery objects by adding filters and ordering.

  • Declaration

    Objective-C

    - (nonnull id)init;
  • The FIRFirestore for the Firestore database (useful for performing transactions, etc.).

    Declaration

    Swift

    var firestore: FIRFirestore { get }

    Objective-C

    @property (readonly, strong, nonatomic) FIRFirestore *_Nonnull firestore;
  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must be equal to the specified value.

    Declaration

    Swift

    func whereField(_ field: String, isEqualTo value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereField:(nonnull NSString *)field
                                isEqualTo:(nonnull id)value;

    Parameters

    field

    The name of the field to compare.

    value

    The value the field must be equal to.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must be equal to the specified value.

    Declaration

    Swift

    func whereField(_ path: FIRFieldPath, isEqualTo value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereFieldPath:(nonnull FIRFieldPath *)path
                                    isEqualTo:(nonnull id)value;

    Parameters

    path

    The path of the field to compare.

    value

    The value the field must be equal to.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must be less than the specified value.

    Declaration

    Swift

    func whereField(_ field: String, isLessThan value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereField:(nonnull NSString *)field
                               isLessThan:(nonnull id)value;

    Parameters

    field

    The name of the field to compare.

    value

    The value the field must be less than.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must be less than the specified value.

    Declaration

    Swift

    func whereField(_ path: FIRFieldPath, isLessThan value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereFieldPath:(nonnull FIRFieldPath *)path
                                   isLessThan:(nonnull id)value;

    Parameters

    path

    The path of the field to compare.

    value

    The value the field must be less than.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must be less than or equal to the specified value.

    Declaration

    Swift

    func whereField(_ field: String, isLessThanOrEqualTo value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereField:(nonnull NSString *)field
                      isLessThanOrEqualTo:(nonnull id)value;

    Parameters

    field

    The name of the field to compare

    value

    The value the field must be less than or equal to.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must be less than or equal to the specified value.

    Declaration

    Swift

    func whereField(_ path: FIRFieldPath, isLessThanOrEqualTo value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereFieldPath:(nonnull FIRFieldPath *)path
                          isLessThanOrEqualTo:(nonnull id)value;

    Parameters

    path

    The path of the field to compare

    value

    The value the field must be less than or equal to.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must greater than the specified value.

    Declaration

    Swift

    func whereField(_ field: String, isGreaterThan value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereField:(nonnull NSString *)field
                            isGreaterThan:(nonnull id)value;

    Parameters

    field

    The name of the field to compare

    value

    The value the field must be greater than.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must greater than the specified value.

    Declaration

    Swift

    func whereField(_ path: FIRFieldPath, isGreaterThan value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereFieldPath:(nonnull FIRFieldPath *)path
                                isGreaterThan:(nonnull id)value;

    Parameters

    path

    The path of the field to compare

    value

    The value the field must be greater than.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must be greater than or equal to the specified value.

    Declaration

    Swift

    func whereField(_ field: String, isGreaterThanOrEqualTo value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereField:(nonnull NSString *)field
                   isGreaterThanOrEqualTo:(nonnull id)value;

    Parameters

    field

    The name of the field to compare

    value

    The value the field must be greater than.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery with the additional filter that documents must contain the specified field and the value must be greater than or equal to the specified value.

    Declaration

    Swift

    func whereField(_ path: FIRFieldPath, isGreaterThanOrEqualTo value: Any) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryWhereFieldPath:(nonnull FIRFieldPath *)path
                       isGreaterThanOrEqualTo:(nonnull id)value;

    Parameters

    path

    The path of the field to compare

    value

    The value the field must be greater than.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that’s additionally sorted by the specified field.

    Declaration

    Swift

    func order(by field: String) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryOrderedByField:(nonnull NSString *)field;

    Parameters

    field

    The field to sort by.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that’s additionally sorted by the specified field.

    Declaration

    Swift

    func order(by path: FIRFieldPath) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryOrderedByFieldPath:(nonnull FIRFieldPath *)path;

    Parameters

    path

    The field to sort by.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that’s additionally sorted by the specified field, optionally in descending order instead of ascending.

    Declaration

    Swift

    func order(by field: String, descending: Bool) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryOrderedByField:(nonnull NSString *)field
                                   descending:(BOOL)descending;

    Parameters

    field

    The field to sort by.

    descending

    Whether to sort descending.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that’s additionally sorted by the specified field, optionally in descending order instead of ascending.

    Declaration

    Swift

    func order(by path: FIRFieldPath, descending: Bool) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryOrderedByFieldPath:(nonnull FIRFieldPath *)path
                                       descending:(BOOL)descending;

    Parameters

    path

    The field to sort by.

    descending

    Whether to sort descending.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that’s additionally limited to only return up to the specified number of documents.

    Declaration

    Swift

    func limit(to limit: Int) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryLimitedTo:(NSInteger)limit;

    Parameters

    limit

    The maximum number of items to return.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that starts at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.

    Declaration

    Swift

    func start(atDocument document: FIRDocumentSnapshot) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryStartingAtDocument:
        (nonnull FIRDocumentSnapshot *)document;

    Parameters

    document

    The snapshot of the document to start at.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that starts at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

    Declaration

    Swift

    func start(at fieldValues: [Any]) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryStartingAtValues:(nonnull NSArray *)fieldValues;

    Parameters

    fieldValues

    The field values to start this query at, in order of the query’s order by.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that starts after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.

    Declaration

    Swift

    func start(afterDocument document: FIRDocumentSnapshot) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryStartingAfterDocument:
        (nonnull FIRDocumentSnapshot *)document;

    Parameters

    document

    The snapshot of the document to start after.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that starts after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

    Declaration

    Swift

    func start(after fieldValues: [Any]) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryStartingAfterValues:(nonnull NSArray *)fieldValues;

    Parameters

    fieldValues

    The field values to start this query after, in order of the query’s order by.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that ends before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.

    Declaration

    Swift

    func end(beforeDocument document: FIRDocumentSnapshot) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryEndingBeforeDocument:
        (nonnull FIRDocumentSnapshot *)document;

    Parameters

    document

    The snapshot of the document to end before.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that ends before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

    Declaration

    Swift

    func end(before fieldValues: [Any]) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryEndingBeforeValues:(nonnull NSArray *)fieldValues;

    Parameters

    fieldValues

    The field values to end this query before, in order of the query’s order by.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that ends at the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.

    Declaration

    Swift

    func end(atDocument document: FIRDocumentSnapshot) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryEndingAtDocument:
        (nonnull FIRDocumentSnapshot *)document;

    Parameters

    document

    The snapshot of the document to end at.

    Return Value

    The created FIRQuery.

  • Creates and returns a new FIRQuery that ends at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

    Declaration

    Swift

    func end(at fieldValues: [Any]) -> Query

    Objective-C

    - (nonnull FIRQuery *)queryEndingAtValues:(nonnull NSArray *)fieldValues;

    Parameters

    fieldValues

    The field values to end this query at, in order of the query’s order by.

    Return Value

    The created FIRQuery.