whereFieldPath method

Query<T> whereFieldPath(
  1. FieldPath fieldPath,
  2. WhereFilter op,
  3. Object? value
)

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> whereFieldPath(
  FieldPath fieldPath,
  WhereFilter op,
  Object? value,
) {
  return whereFilter(Filter.where(fieldPath, op, value));
}