selectRows<T> method

Future<List<T>> selectRows<T>(
  1. List<String> fields,
  2. RowDecoder<T> decoder
)

Reads only the requested Dart fields and returns an immutable list. Field validation precedes execution; decoder failures propagate.

Implementation

Future<List<T>> selectRows<T>(
  List<String> fields,
  RowDecoder<T> decoder,
) async {
  if (fields.isEmpty || fields.toSet().length != fields.length) {
    throw ArgumentError('Invalid selection');
  }
  final columns = fields
      .map((f) => quoteIdentifier(definition.column(f).name))
      .join(', ');
  final bindings = _bindings();
  final result = await session.run(
    'SELECT $columns FROM $_onlyTable${_readSuffix(bindings)}',
    parameters: bindings.values,
  );
  return List<T>.unmodifiable(result.rows.map(decoder));
}