The superclass for all databases class generated by drift.
- Inheritance
-
- Object
- DatabaseConnectionUser
- GeneratedDatabase
- 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< table, Insertable insertable, {int? startIndex}) → StatementBufferObject, dynamic> > -
Writes column names and
VALUESfor an insert statement.inherited -
$writeUpdateInsertable(
GeneratedTable< Object, GeneratedTable< table, Insertable insertable, {int? startIndex}) → StatementBufferObject, dynamic> > -
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< variables = const [], Set<Object> >SchemaEntityWithResultSet< ? updates}) → Future<Object, ResultSet< >Object, dynamic> >int> -
Executes a custom insert statement and returns the last inserted rowid.
inherited
-
customSelect(
String query, {List< Variable< variables = const [], Set<Object> >SchemaEntityWithResultSet< readsFrom = const {}, bool isReadOnly = true}) → Selectable<Object, ResultSet< >Object, dynamic> >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< variables = const [], Set<Object> >SchemaEntityWithResultSet< readsFrom = const {}, bool isReadOnly = true}) → Selectable<Object, ResultSet< >Object, dynamic> >T> -
A variant of customSelect that uses
createMapperto 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< variables = const [], Set<Object> >SchemaEntityWithResultSet< readsFrom = const {}, bool isReadOnly = true}) → Selectable<Object, ResultSet< >Object, dynamic> >T> -
Like customSelectMapped, but allows
createMapperto be asynchronous and to fire off additional queries.inherited -
customStatement(
String statement, [List< Variable< args = const []]) → Future<Object> >void> -
Executes the custom sql
statementon the database.inherited -
customUpdate(
String query, {List< Variable< variables = const [], Set<Object> >SchemaEntityWithResultSet< ? updates, UpdateKind? updateKind}) → Future<Object, ResultSet< >Object, dynamic> >int> -
Executes a custom delete or update statement and returns the amount of
rows that have been changed.
You can use the
updatesparameter 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 theupdateKindparameter 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< variables = const [], Set<Object> >SchemaEntityWithResultSet< ? updates, UpdateKind? updateKind}) → Future<Object, ResultSet< >Object, dynamic> >RawResultSet> -
Runs a
INSERT,UPDATEorDELETEstatement 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
fnafter 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
actionin 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
tableby using InsertStatement.insert.inherited -
markTablesUpdated(
Iterable< GeneratedTable< tables) → voidObject, GeneratedTable< >Object, dynamic> > -
Marks the
tablesas 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
updatesto 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
actionwith calls intercepted by the giveninterceptorinherited -
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< columns) → SelectStatementObject> > -
Creates a select statement without a
FROMclause selectingcolumns.inherited -
selectOnly(
ResultSet< Object, ResultSet< table, {bool distinct = false}) → SelectStatementObject, dynamic> > -
Starts a complex statement on
tablethat doesn't necessarily use all oftable'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
actionin 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