averageCollection function

Future<double> averageCollection(
  1. String collectionPath,
  2. String field, {
  3. List<Where> where = const [],
  4. List<OrderBy> orderBy = const [],
  5. int? limit,
  6. int? limitToLast,
  7. bool collectionGroup = false,
})

Averages field over what a query matches, computed by the server.

As with sumCollection, documents without a numeric value for the field are skipped — they do not pull the average toward zero. An empty result set has no average and answers 0.

Implementation

Future<double> averageCollection(
  String collectionPath,
  String field, {
  List<Where> where = const [],
  List<OrderBy> orderBy = const [],
  int? limit,
  int? limitToLast,
  bool collectionGroup = false,
}) => _aggregate(
  fdbFsAverage,
  'average',
  collectionPath,
  field,
  where: where,
  orderBy: orderBy,
  limit: limit,
  limitToLast: limitToLast,
  collectionGroup: collectionGroup,
);