CreateIndexOperation constructor

CreateIndexOperation(
  1. Db db,
  2. DbCollection collection,
  3. Object fieldOrSpec,
  4. CreateIndexOptions? indexOptions, {
  5. Connection? connection,
  6. Map<String, Object>? rawOptions,
})

Implementation

CreateIndexOperation(Db db, DbCollection collection, this.fieldOrSpec,
    CreateIndexOptions? indexOptions,
    {Connection? connection, Map<String, Object>? rawOptions})
    : super(db, <String, Object>{...?indexOptions?.options, ...?rawOptions},
          collection: collection,
          aspect: Aspect.writeOperation,
          connection: connection) {
  // parseIndexOptions alway returns a filled "keyName" and a "keyFieldHash"
  // elements
  var indexParameters = parseIndexOptions(fieldOrSpec);
  final indexName = options[keyName] != null && options[keyName] is String
      ? options[keyName] as String
      : indexParameters[keyName] as String;
  indexes = {keyName: indexName, keyKey: indexParameters[keyFieldHash]!};
  options.remove(keyName);
}