Stay organized with collections Save and categorize content based on your preferences.
A Filter
represents a restriction on one or more field values and can be used to refine the results of a Query. Filters
s are created by invoking , , or and can then be passed to to create a new Query instance that also contains this Filter
.
static and(...filters: Filter[]): Filter;
Creates and returns a new [Filter]Filter that is a conjunction of the given Filters. A conjunction filter includes a document if it satisfies all of the given Filters.
The returned Filter can be applied to [Query.where()], [Filter.or()], or [Filter.and()]. When applied to a [Query]Query it requires that documents must satisfy one of the provided Filters.
Parameter Name Descriptionfilters
Filter[]
Optional. The Filters for AND operation. These must be created with calls to , , or .
Returns Type DescriptionFilter
{Filter} The created Filter.
Example
let collectionRef = firestore.collection('col');
// doc.foo == 'bar' && doc.baz > 0
let andFilter = Filter.and(Filter.where('foo', '==', 'bar'), Filter.where('baz', '>', 0));
collectionRef.where(andFilter).get().then(querySnapshot => {
querySnapshot.forEach(documentSnapshot => {
console.log(`Found document at ${documentSnapshot.ref.path}`);
});
});
or(filters)
static or(...filters: Filter[]): Filter;
Creates and returns a new [Filter]Filter that is a disjunction of the given Filters. A disjunction filter includes a document if it satisfies any of the given Filters.
The returned Filter can be applied to [Query.where()], [Filter.or()], or [Filter.and()]. When applied to a [Query]Query it requires that documents must satisfy one of the provided Filters.
Parameter Name Descriptionfilters
Filter[]
Optional. The Filters for OR operation. These must be created with calls to , , or .
Returns Type DescriptionFilter
{Filter} The created Filter.
Example
let collectionRef = firestore.collection('col');
// doc.foo == 'bar' || doc.baz > 0
let orFilter = Filter.or(Filter.where('foo', '==', 'bar'), Filter.where('baz', '>', 0));
collectionRef.where(orFilter).get().then(querySnapshot => {
querySnapshot.forEach(documentSnapshot => {
console.log(`Found document at ${documentSnapshot.ref.path}`);
});
});
where(fieldPath, opStr, value)
static where(fieldPath: string | firestore.FieldPath, opStr: firestore.WhereFilterOp, value: unknown): Filter;
Creates and returns a new [Filter]Filter, which can be applied to [Query.where()], [Filter.or()], or [Filter.and()]. When applied to a [Query]Query it requires that documents must contain the specified field and that its value should satisfy the relation constraint provided.
Parameters Name DescriptionfieldPath
string | FirebaseFirestore.FieldPath
The name of a property value to compare.
opStr
firestore.WhereFilterOp
A comparison operation in the form of a string. Acceptable operator strings are "<", "<=", "==", "!=", ">=", ">", "array-contains", "in", "not-in", and "array-contains-any".
value
unknown
The value to which to compare the field for inclusion in a query.
Returns Type DescriptionFilter
{Filter} The created Filter.
Example
let collectionRef = firestore.collection('col');
collectionRef.where(Filter.where('foo', '==', 'bar')).get().then(querySnapshot => {
querySnapshot.forEach(documentSnapshot => {
console.log(`Found document at ${documentSnapshot.ref.path}`);
});
});
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4