getAColumnFromWithTableName<T> method

Future<List<T>> getAColumnFromWithTableName<T>(
  1. String columnName,
  2. String table, {
  3. String? afterWhere,
  4. List<Object?>? whereArgs,
})

Like getAColumnFrom but accepts an arbitrary table name (or a join expression). Useful for querying non-entity tables such as sqlite_master or to run joined queries with table aliases.

Example:

final names = await DataAccess.instance
    .getAColumnFromWithTableName<String>(
      'c.name',
      'Custom c, Profile p',
      afterWhere: 'c.profile = p.id AND p.name = ?',
      whereArgs: ['faithful'],
    );

Implementation

Future<List<T>> getAColumnFromWithTableName<T>(
  String columnName,
  String table, {
  String? afterWhere,
  List<Object?>? whereArgs,
}) => _guard('getAColumnFromWithTableName', <T>[], () async {
  final List<Map<String, Object?>> rows = await _selectWhere(
    columnRef(columnName),
    table,
    afterWhere,
    whereArgs,
  );
  return rows
      .map((Map<String, Object?> row) => row[columnName] as T)
      .toList();
});