Interface that a database adapter must implement.
Warning
This interface is NOT stable yet, while subclasses of DatabaseAdapter
is possible outside package:typed_sql
, newer versions of this package
may add new methods (remove existing) without a major version bump!
Constructors
- DatabaseAdapter.new()
-
DatabaseAdapter.fromFuture(Future<
DatabaseAdapter> adapter) -
Wrap
adapter
as DatabaseAdapter.factory -
DatabaseAdapter.postgres(Pool<
void> pool) -
Create a Postgres DatabaseAdapter using
pool
.factory - DatabaseAdapter.postgresTestDatabase({String? host, int? port, String? database, String? user, String? password})
-
Create an ephemeral postgres database for testing.
factory
- DatabaseAdapter.sqlite3(Uri uri)
-
Create an SQLite3 DatabaseAdapter from
uri
.factory - DatabaseAdapter.sqlite3TestDatabase()
-
Create an SQLite in-memory database for testing.
factory
- DatabaseAdapter.withLogging(DatabaseAdapter adapter, void log(String message))
-
Wrap
adapter
such that all queries are written tolog
.factory - DatabaseAdapter.withNopClose(DatabaseAdapter adapter)
-
Wrap
adapter
such that close is a no-op!factory -
DatabaseAdapter.withOnClose(DatabaseAdapter adapter, Future<
void> onClosed({required bool force})) -
Wrap
adapter
such that close callsonClosed
instead ofadapter.close
.factory
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
-
close(
{bool force = false}) → Future< void> - Close the database connection pool.
-
execute(
String sql, List< Object?> params) → Future<QueryResult> -
Execute a single
sql
query with positionalparams
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
query(
String sql, List< Object?> params) → Stream<RowReader> -
Execute
sql
query with positionalparams
.inherited -
script(
String sql) → Future< void> -
Execute an
sql
script that may contain multiple statements.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
transact<
T> (Future< T> fn(Executor tx)) → Future<T> -
Begin a transaction / save-point and call
fn
before committing the transaction.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited