mapFromRowWithAlias method

Future<D> mapFromRowWithAlias(
  1. QueryRow row,
  2. Map<String, String> alias
)

Like mapFromRow, but maps columns from the result through alias.

This is used internally by drift to support mapping to a table from a select statement with different column names. For instance, for:

CREATE TABLE tbl (foo, bar);

query: SELECT foo AS c1, bar AS c2 FROM tbl;

Drift would generate code to call this method with 'c1': 'foo' and 'c2': 'bar' in alias.

Implementation

Future<D> mapFromRowWithAlias(QueryRow row, Map<String, String> alias) async {
  return await map({
    for (final entry in row.data.entries) alias[entry.key]!: entry.value,
  });
}