DatabaseConnectionUser class abstract base

The shared base class for drift databases and database accessors.

Constructors

DatabaseConnectionUser()

Properties

attachedDatabase → GeneratedDatabase
The database class that this user is attached to.
no setter
dialect → DriftDialect
The DriftDialect implementation for this opened database.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

$expandVar(int start, int amount) → String
Used by generated code to expand array variables.
$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.
$writeInsertable(GeneratedTable<Object, GeneratedTable<Object, dynamic>> table, Insertable insertable, {int? startIndex}) → StatementBuffer
Writes column names and VALUES for an insert statement.
$writeUpdateInsertable(GeneratedTable<Object, GeneratedTable<Object, dynamic>> table, Insertable insertable, {int? startIndex}) → StatementBuffer
Writes column names and values for an update statement.
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.
batch(FutureOr<void> runInBatch(Batch batch)) → Future<BatchResult>
Runs statements inside a batch.
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.
currentSession() → Future<DriftSession>
The current DriftSession that this database will use to run statements.
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.
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.
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.
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.
customStatement(String statement, [List<Variable<Object>> args = const []]) → Future<void>
Executes the custom sql statement on the database.
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.
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.
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.
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.
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.
initialize() → Future<void>
Waits for the database to be initialized, meaning that all connections are fully set up and migrations ran.
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.
markTablesUpdated(Iterable<GeneratedTable<Object, GeneratedTable<Object, dynamic>>> tables) → void
Marks the tables as updated.
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.
runStatement(SqlStatement statement) → Future<QueryResult>
Runs the compiled SqlStatement on the currentSession.
runWithInterceptor<T>(Future<T> action(), {required QueryInterceptor interceptor}) → Future<T>
Executes action with calls intercepted by the given interceptor
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.
selectExpressions(Iterable<Expression<Object>> columns) → SelectStatement
Creates a select statement without a FROM clause selecting columns.
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.
tableUpdates([TableUpdateQuery query = const TableUpdateQuery.any()]) → Stream<Set<TableUpdate>>
Listen for table updates reported through notifyUpdates.
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.
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.

Operators

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