rowId property

Expression<int> get rowId

In sqlite, each table that hasn't been created with the WITHOUT ROWID modifier has a row id. When the table has a single primary key column which is an integer, that column is an alias to the row id in sqlite3.

If the row id has not explicitly been declared as a column aliasing it, the rowId will not be part of a drift-generated data class. In this case, the rowId getter can be used to refer to a table's row id in a query.

Implementation

@pragma('drift:v3-moved-to', 'drift_sqlite')
Expression<int> get rowId {
  if (withoutRowId) {
    throw ArgumentError('Cannot use rowId on a table without a rowid!');
  }

  return GeneratedColumn<int>(
    '_rowid_',
    aliasedName,
    false,
    type: DriftSqlType.int,
  );
}