docs-devsite/firestore_.query.md
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.
<b>Signature:</b>
export declare class Query<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)() | Constructs a new instance of the <code>Query</code> class |
| Property | Modifiers | Type | Description |
|---|---|---|---|
| converter | FirestoreDataConverter<!-- --><AppModelType, DbModelType> | null | If provided, the <code>FirestoreDataConverter</code> associated with this instance. | |
| firestore | Firestore | The <code>Firestore</code> 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 <code>NewDbModelType</code> and your custom type <code>NewAppModelType</code>. |
Constructs a new instance of the Query class
<b>Signature:</b>
protected constructor();
If provided, the FirestoreDataConverter associated with this instance.
<b>Signature:</b>
readonly converter: FirestoreDataConverter<AppModelType, DbModelType> | null;
The Firestore instance for the Firestore database (useful for performing transactions, etc.).
<b>Signature:</b>
readonly firestore: Firestore;
The type of this Firestore reference.
<b>Signature:</b>
readonly type: 'query' | 'collection';
Removes the current converter.
<b>Signature:</b>
withConverter(converter: null): Query<DocumentData, DocumentData>;
| Parameter | Type | Description |
|---|---|---|
| converter | null | <code>null</code> removes the current converter. |
<b>Returns:</b>
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<!-- -->.
<b>Signature:</b>
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. |
<b>Returns:</b>
Query<!-- --><NewAppModelType, NewDbModelType>
A Query that uses the provided converter.