where method
Creates and returns a new Query with the additional filter that documents must contain the specified field and that its value should satisfy the relation constraint provided.
This function returns a new (immutable) instance of the Query (rather than modify the existing instance) to impose the filter.
fieldPath
: The name of a property value to compare.op
: A comparison operation in the form of a string. Acceptable operator strings are "<", "<=", "==", "!=", ">=", ">", "array-contains", "in", "not-in", and "array-contains-any".value
: The value to which to compare the field for inclusion in a query.
final collectionRef = firestore.collection('col');
collectionRef.where('foo', WhereFilter.equal, 'bar').get().then((querySnapshot) {
querySnapshot.forEach((documentSnapshot) {
print('Found document at ${documentSnapshot.ref.path}');
});
});
Implementation
Query<T> where(Object path, WhereFilter op, Object? value) {
final fieldPath = FieldPath.from(path);
return whereFieldPath(fieldPath, op, value);
}