endBefore method

Query<T> endBefore(
  1. List<Object?> fieldValues
)

Creates and returns a new Query that ends before the set of field values relative to the order of the query. The order of the provided values must match the order of the order by clauses of the query.

  • fieldValues: The field values to end this query before, in order of the query's order by.
final query = firestore.collection('col');

query.orderBy('foo').endBefore(42).get().then((querySnapshot) {
  querySnapshot.forEach((documentSnapshot) {
    print('Found document at ${documentSnapshot.ref.path}');
  });
});

Implementation

Query<T> endBefore(List<Object?> fieldValues) {
  final (endAt, fieldOrders) = _cursorFromValues(
    fieldValues: fieldValues,
    before: true,
  );

  final options = _queryOptions.copyWith(
    fieldOrders: fieldOrders,
    endAt: endAt,
  );
  return Query<T>._(
    firestore: firestore,
    queryOptions: options,
  );
}