Query class Stay organized with collections Save and categorize content based on your preferences.
AQuery refers to a query which you can read or listen to. You can also construct refinedQuery objects by adding filters and ordering.
Signature:
exportdeclareclassQuery<AppModelType=DocumentData,DbModelTypeextendsDocumentData=DocumentData>Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)() | Constructs a new instance of theQuery class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| converter | FirestoreDataConverter<AppModelType, DbModelType> | null | If provided, theFirestoreDataConverter associated with this instance. | |
| firestore | Firestore | TheFirestore instance for the Firestore database (useful for performing transactions, etc.). | |
| type | 'query' | 'collection' | The type of this Firestore reference. |
Methods
| Method | Modifiers | Description |
|---|---|---|
| withConverter(converter) | Removes the current converter. | |
| withConverter(converter) | Applies a custom data converter to this query, allowing you to use your own custom model objects with Firestore. When you callgetDocs() with the returned query, the provided converter will convert between Firestore data of typeNewDbModelType and your custom typeNewAppModelType. |
Query.(constructor)
Constructs a new instance of theQuery class
Signature:
protectedconstructor();Query.converter
If provided, theFirestoreDataConverter associated with this instance.
Signature:
readonlyconverter:FirestoreDataConverter<AppModelType,DbModelType>|null;Query.firestore
TheFirestore instance for the Firestore database (useful for performing transactions, etc.).
Signature:
readonlyfirestore:Firestore;Query.type
The type of this Firestore reference.
Signature:
readonlytype:'query'|'collection';Query.withConverter()
Removes the current converter.
Signature:
withConverter(converter:null):Query<DocumentData,DocumentData>;Parameters
| Parameter | Type | Description |
|---|---|---|
| converter | null | null removes the current converter. |
Returns:
Query<DocumentData,DocumentData>
AQuery<DocumentData, DocumentData> that does not use a converter.
Query.withConverter()
Applies a custom data converter to this query, allowing you to use your own custom model objects with Firestore. When you callgetDocs() with the returned query, the provided converter will convert between Firestore data of typeNewDbModelType and your custom typeNewAppModelType.
Signature:
withConverter<NewAppModelType,NewDbModelTypeextendsDocumentData=DocumentData>(converter:FirestoreDataConverter<NewAppModelType,NewDbModelType>):Query<NewAppModelType,NewDbModelType>;Parameters
| Parameter | Type | Description |
|---|---|---|
| converter | FirestoreDataConverter<NewAppModelType, NewDbModelType> | Converts objects to and from Firestore. |
Returns:
Query<NewAppModelType, NewDbModelType>
AQuery that uses the provided converter.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-01-19 UTC.