Query class

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

ConstructorModifiersDescription
(constructor)()Constructs a new instance of theQuery class

Properties

PropertyModifiersTypeDescription
converterFirestoreDataConverter<AppModelType, DbModelType> | nullIf provided, theFirestoreDataConverter associated with this instance.
firestoreFirestoreTheFirestore instance for the Firestore database (useful for performing transactions, etc.).
type'query' | 'collection'The type of this Firestore reference.

Methods

MethodModifiersDescription
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

ParameterTypeDescription
converternullnull 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

ParameterTypeDescription
converterFirestoreDataConverter<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 2026-01-15 UTC.