count static method

A query to output the total number of documents in the collection.

コレクションのドキュメントの全数を出力するためのクエリ。

Implementation

static ModelAggregateQuery<AsyncAggregateValue<int>> count() {
  return ModelAggregateQuery<AsyncAggregateValue<int>>._(
    type: ModelAggregateQueryType.count,
    defaultValue: 0,
    onCreate: (query, collection, onFinished) {
      return AsyncAggregateValue<int>._(
        query: query,
        collection: collection,
        onFinished: onFinished,
      );
    },
    onUpdate: (update, value) async {
      switch (update.status) {
        case ModelUpdateNotificationStatus.added:
        case ModelUpdateNotificationStatus.removed:
          await value.reload();
          break;
        default:
          break;
      }
    },
  );
}