Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference
{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}
A Query
refers to a query which you can read or listen to. You can also construct refined Query
objects by adding filters and ordering.
Signature:
export declare class Query<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>
Constructor | Modifiers | Description |
---|---|---|
(constructor)() | Constructs a new instance of the Query class |
Property | Modifiers | Type | Description |
---|---|---|---|
converter | FirestoreDataConverter<AppModelType, DbModelType> | null | If provided, the FirestoreDataConverter associated with this instance. |
|
firestore | Firestore | The Firestore instance for the Firestore database (useful for performing transactions, etc.). |
|
type | 'query' | 'collection' | The type of this Firestore reference. |
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 call getDocs() with the returned query, the provided converter will convert between Firestore data of type NewDbModelType and your custom type NewAppModelType . |
Constructs a new instance of the Query
class
Signature:
protected constructor();
If provided, the FirestoreDataConverter
associated with this instance.
Signature:
readonly converter: FirestoreDataConverter<AppModelType, DbModelType> | null;
The Firestore
instance for the Firestore database (useful for performing transactions, etc.).
Signature:
readonly firestore: Firestore;
The type of this Firestore reference.
Signature:
readonly type: 'query' | 'collection';
Removes the current converter.
Signature:
withConverter(converter: null): Query<DocumentData, DocumentData>;
Parameter | Type | Description |
---|---|---|
converter | null | null removes the current converter. |
Returns:
Query<DocumentData, DocumentData>
A Query<DocumentData, DocumentData>
that does not use a converter.
Applies a custom data converter to this query, allowing you to use your own custom model objects with Firestore. When you call getDocs() with the returned query, the provided converter will convert between Firestore data of type NewDbModelType
and your custom type NewAppModelType
.
Signature:
withConverter<NewAppModelType, NewDbModelType extends DocumentData = DocumentData>(converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): Query<NewAppModelType, NewDbModelType>;
Parameter | Type | Description |
---|---|---|
converter | FirestoreDataConverter<NewAppModelType, NewDbModelType> | Converts objects to and from Firestore. |
Returns:
Query<NewAppModelType, NewDbModelType>
A Query
that uses the provided converter.