createAggregateCommand static method

DbCommand createAggregateCommand(
  1. Db db,
  2. String collectionName,
  3. List pipeline, {
  4. bool allowDiskUse = false,
  5. Map<String, dynamic>? cursor,
})

Implementation

static DbCommand createAggregateCommand(
    Db db, String collectionName, List pipeline,
    {bool allowDiskUse = false, Map<String, dynamic>? cursor}) {
  var query = {'aggregate': collectionName, 'pipeline': pipeline};

  if (cursor != null) query['cursor'] = cursor;

  if (db.masterConnection.serverCapabilities.aggregationCursor) {
    query['allowDiskUse'] = allowDiskUse;
  }

  return DbCommand(db, SYSTEM_COMMAND_COLLECTION,
      MongoQueryMessage.OPTS_NO_CURSOR_TIMEOUT, 0, -1, query, null);
}