GeneratedDatabase class abstract base

The superclass for all databases class generated by drift.

Inheritance
Available extensions

Constructors

GeneratedDatabase(DriftConnection _connection)
Opens a drift database backed by a given connection.

Properties

attachedDatabase → GeneratedDatabase
The database class that this user is attached to.
no setteroverride
destructiveFallback → MigrationStrategy

Available on GeneratedDatabase, provided by the DestructiveMigrationExtension extension

Provides a destructive MigrationStrategy that will delete and then re-create all tables, triggers and indices.
no setter
dialect → DriftDialect
The DriftDialect implementation for this opened database.
no setteroverride
dialectOptions → Map<KnownSqlDialect, Object>
Dialect-specific options passed to a DriftDialectFactory to construct the SQL dialect used on this database.
no setter
enableMigrations ↔ bool
Whether the database should attempt to run migrations when opened.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
migration → MigrationStrategy
Defines the migration strategy that will determine how to deal with an increasing schemaVersion. The default value only supports creating the database by creating all tables known in this database. When you have changes in your schema, you'll need a custom migration strategy to create the new tables or change the columns.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schema → DatabaseSchema
The schema of this database, providing access to underlying DatabaseSchema.entities.
no setter
schemaVersion → int
Specify the schema version of your database. Whenever you change or add tables, you should bump this field and provide a migration strategy.
no setter
streamUpdateRules → StreamQueryUpdateRules
The collection of update rules contains information on how updates on tables result in other updates, for instance due to a trigger.
no setter

Methods

$expandVar(int start, int amount) → String
Used by generated code to expand array variables.
inherited
$write(SqlComponent component, {bool? hasMultipleTables, int? startIndex}) → StatementBuffer
Will be used by generated code to resolve inline Dart components in sql by writing the component.
inherited
$writeInsertable(GeneratedTable<Object, GeneratedTable<Object, dynamic>> table, Insertable insertable, {int? startIndex}) → StatementBuffer
Writes column names and VALUES for an insert statement.
inherited
$writeUpdateInsertable(GeneratedTable<Object, GeneratedTable<Object, dynamic>> table, Insertable insertable, {int? startIndex}) → StatementBuffer
Writes column names and values for an update statement.
inherited
alias<Row extends Object, RS extends ResultSet<Row, RS>>(ResultSet<Row, RS> table, String alias) → RS
Creates a copy of the table with an alias so that it can be used in the same query more than once.
inherited
batch(FutureOr<void> runInBatch(Batch batch)) → Future<BatchResult>
Runs statements inside a batch.
inherited
close() → Future<void>
Closes this drift database and releases associated resources.
count<Row extends Object, RS extends ResultSet<Row, RS>>(ResultSet<Row, RS> table, {Expression<bool> where(RS row)?}) → SingleSelectable<int>
Counts the amount of rows in a table.
inherited
createMigrator() → Migrator
Creates a Migrator instance useful for running schema-altering statements against this database.
currentSession() → Future<DriftSession>
The current DriftSession that this database will use to run statements.
inherited
customInsert(String query, {List<Variable<Object>> variables = const [], Set<SchemaEntityWithResultSet<Object, ResultSet<Object, dynamic>>>? updates}) → Future<int>
Executes a custom insert statement and returns the last inserted rowid.
inherited
customSelect(String query, {List<Variable<Object>> variables = const [], Set<SchemaEntityWithResultSet<Object, ResultSet<Object, dynamic>>> readsFrom = const {}, bool isReadOnly = true}) → Selectable<CustomRow>
Creates a custom select statement from the given sql query.
inherited
customSelectMapped<T>({required String query, required T Function(RawRow) createMapper(RawResultSet), List<Variable<Object>> variables = const [], Set<SchemaEntityWithResultSet<Object, ResultSet<Object, dynamic>>> readsFrom = const {}, bool isReadOnly = true}) → Selectable<T>
A variant of customSelect that uses createMapper to obtain a select statement for which rows can be mapped to a custom Dart type.
inherited
customSelectMappedAsync<T>({required String query, required Future<T> Function(RawRow) createMapper(RawResultSet), List<Variable<Object>> variables = const [], Set<SchemaEntityWithResultSet<Object, ResultSet<Object, dynamic>>> readsFrom = const {}, bool isReadOnly = true}) → Selectable<T>
Like customSelectMapped, but allows createMapper to be asynchronous and to fire off additional queries.
inherited
customStatement(String statement, [List<Variable<Object>> args = const []]) → Future<void>
Executes the custom sql statement on the database.
inherited
customUpdate(String query, {List<Variable<Object>> variables = const [], Set<SchemaEntityWithResultSet<Object, ResultSet<Object, dynamic>>>? updates, UpdateKind? updateKind}) → Future<int>
Executes a custom delete or update statement and returns the amount of rows that have been changed. You can use the updates parameter so that drift knows which tables are affected by your query. All select streams that depend on a table specified there will then update their data. For more accurate results, you can also set the updateKind parameter to UpdateKind.delete or UpdateKind.update. This is optional, but can improve the accuracy of query updates, especially when using triggers.
inherited
customWriteReturning(String query, {List<Variable<Object>> variables = const [], Set<SchemaEntityWithResultSet<Object, ResultSet<Object, dynamic>>>? updates, UpdateKind? updateKind}) → Future<RawResultSet>
Runs a INSERT, UPDATE or DELETE statement returning rows.
inherited
delete<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table) → DeleteStatement<Row, RS>
Starts a DeleteStatement that can be used to delete rows from a table.
inherited
doWhenOpened<T>(FutureOr<T> fn(DriftSession e)) → Future<T>
Performs the async fn after this executor is ready, or directly if it's already ready.
inherited
exclusively<T>(Future<T> action()) → Future<T>
Obtains an exclusive lock on the current database context, runs action in it and then releases the lock.
inherited
initialize() → Future<void>
Waits for the database to be initialized, meaning that all connections are fully set up and migrations ran.
inherited
into<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table) → InsertStatement<Row, RS>
Starts an InsertStatement for a given table. You can use that statement to write data into the table by using InsertStatement.insert.
inherited
markTablesUpdated(Iterable<GeneratedTable<Object, GeneratedTable<Object, dynamic>>> tables) → void
Marks the tables as updated.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyUpdates(Set<TableUpdate> updates) → void
Dispatches the set of updates to the stream query manager.
inherited
runStatement(SqlStatement statement) → Future<QueryResult>
Runs the compiled SqlStatement on the currentSession.
inherited
runWithInterceptor<T>(Future<T> action(), {required QueryInterceptor interceptor}) → Future<T>
Executes action with calls intercepted by the given interceptor
inherited
select<Row extends Object, RS extends ResultSet<Row, RS>>(ResultSet<Row, RS> table, {bool distinct = false}) → SingleTableSelectStatement<Row, RS>
Starts a query on the given table.
inherited
selectExpressions(Iterable<Expression<Object>> columns) → SelectStatement
Creates a select statement without a FROM clause selecting columns.
inherited
selectOnly(ResultSet<Object, ResultSet<Object, dynamic>> table, {bool distinct = false}) → SelectStatement
Starts a complex statement on table that doesn't necessarily use all of table's columns.
inherited
tableUpdates([TableUpdateQuery query = const TableUpdateQuery.any()]) → Stream<Set<TableUpdate>>
Listen for table updates reported through notifyUpdates.
inherited
toString() → String
A string representation of this object.
inherited
transaction<T>(Future<T> action(), {TransactionOptions? options}) → Future<T>
Executes action in a transaction, which means that all its queries and updates will be called atomically.
inherited
update<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table) → UpdateStatement<Row, RS>
Starts an UpdateStatement for the given table. You can use that statement to update individual rows in that table by setting a where clause on that table and then use UpdateStatement.write.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited