DB class abstract final

Database access.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Properties

inTransaction → bool
no setter
manager → DatabaseManager
no setter
totalQueryDuration → Duration
Time the current request, job or command has spent in queries.
no setter

Static Methods

connection([String? name]) → Future<DatabaseDriver>
insertGetId(String sql, [Object? bindings = const <Object?>[]]) → Future<Object?>
listen(void listener(QueryExecuted event)) → void
Calls listener after every query (DB::listen): SQL, bindings, duration and connection, for debugging and slow-query logging.
listenTransactions(void listener(TransactionEvent event)) → void
Calls listener when a transaction begins, commits and rolls back.
raw(String sql, [List<Object?> bindings = const []]) → RawExpression
Raw SQL expression for use inside the query builder.
select(String sql, [Object? bindings = const <Object?>[]]) → Future<List<Map<String, Object?>>>
Raw query; bindings is a List for ? or a Map for :name.
statement(String sql, [Object? bindings = const <Object?>[]]) → Future<int>
table(String table, {String? connection}) → QueryBuilder
Fluent query on table (DB::table()).
transaction<T>(Future<T> body(), {String? connection, int attempts = 1}) → Future<T>
whenQueryingForLongerThan(Duration threshold, void handler(QueryExecuted event)) → void
Calls handler once the current request, job or command has spent more than threshold in queries (DB::whenQueryingForLongerThan).
withQueryCount<T>(FutureOr<T> body()) → Future<(T, int, List<QueryExecuted>)>
Runs body and returns its result, how many queries it ran and the queries themselves: