The shared base class for drift databases and database accessors.
Constructors
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< table, Insertable insertable, {int? startIndex}) → StatementBufferObject, dynamic> > -
Writes column names and
VALUESfor an insert statement. -
$writeUpdateInsertable(
GeneratedTable< Object, GeneratedTable< table, Insertable insertable, {int? startIndex}) → StatementBufferObject, dynamic> > - 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< variables = const [], Set<Object> >SchemaEntityWithResultSet< ? updates}) → Future<Object, ResultSet< >Object, dynamic> >int> - Executes a custom insert statement and returns the last inserted rowid.
-
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. -
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. -
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. -
customStatement(
String statement, [List< Variable< args = const []]) → Future<Object> >void> -
Executes the custom sql
statementon the database. -
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. -
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. -
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
fnafter 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
actionin 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
tableby using InsertStatement.insert. -
markTablesUpdated(
Iterable< GeneratedTable< tables) → voidObject, GeneratedTable< >Object, dynamic> > -
Marks the
tablesas updated. -
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. -
runStatement(
SqlStatement statement) → Future< QueryResult> - Runs the compiled SqlStatement on the currentSession.
-
runWithInterceptor<
T> (Future< T> action(), {required QueryInterceptor interceptor}) → Future<T> -
Executes
actionwith calls intercepted by the giveninterceptor -
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< columns) → SelectStatementObject> > -
Creates a select statement without a
FROMclause selectingcolumns. -
selectOnly(
ResultSet< Object, ResultSet< table, {bool distinct = false}) → SelectStatementObject, dynamic> > -
Starts a complex statement on
tablethat doesn't necessarily use all oftable'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
actionin 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