orderBy method

  1. @override
Future<List<T>> orderBy(
  1. List<OrderBy> orderBy, {
  2. int? limit,
})
override

Get a list of documents from the collection as a list ordered by the orderBy

limit: optionally provide a maximum value of items to be returned

throws a MissingValueException when no orderBys are given

Implementation

@override
Future<List<T>> orderBy(List<OrderBy> orderBy, {int? limit}) async {
  if (orderBy.isEmpty) throw MissingValueException(OrderBy);

  final query = ref.sort(orderBy).limitIfNotNull(limit);

  final snapshot = await query.get();

  return snapshot.docs.toListT();
}