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.
-
The
FIRFirestore
for the Firestore database (useful for performing transactions, etc.).Declaration
Objective-C
@property (readonly, strong, nonatomic) FIRFirestore *_Nonnull firestore;
-
Reads the documents matching this query.
This method attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. See the
getDocuments(source:completion:)
method to change this behavior.Declaration
Objective-C
- (void)getDocumentsWithCompletion:(nonnull FIRQuerySnapshotBlock)completion;
Parameters
completion
a block to execute once the documents have been successfully read. documentSet will be
nil
only if error isnon-nil
. -
Reads the documents matching this query.
Declaration
Objective-C
- (void)getDocumentsWithSource:(FIRFirestoreSource)source completion:(nonnull FIRQuerySnapshotBlock)completion;
Parameters
source
indicates whether the results should be fetched from the cache only (
Source.cache
), the server only (Source.server
), or to attempt the server and fall back to the cache (Source.default
).completion
a block to execute once the documents have been successfully read. documentSet will be
nil
only if error isnon-nil
. -
Attaches a listener for QuerySnapshot events.
Declaration
Objective-C
- (nonnull id<FIRListenerRegistration>)addSnapshotListener: (nonnull FIRQuerySnapshotBlock)listener;
Parameters
listener
The listener to attach.
Return Value
A FIRListenerRegistration that can be used to remove this listener.
-
Attaches a listener for QuerySnapshot events.
Declaration
Objective-C
- (nonnull id<FIRListenerRegistration>) addSnapshotListenerWithIncludeMetadataChanges:(BOOL)includeMetadataChanges listener: (nonnull FIRQuerySnapshotBlock) listener;
Parameters
includeMetadataChanges
Whether metadata-only changes (i.e. only
FIRDocumentSnapshot.metadata
changed) should trigger snapshot events.listener
The listener to attach.
Return Value
A FIRListenerRegistration that can be used to remove this listener.
-
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
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
Objective-C
- (nonnull FIRQuery *)queryWhereFieldPath:(nonnull FIRFieldPath *)path isEqualTo:(