PostgresDatabase class final
A PostgreSQL database backed by one connection or a lazy connection pool.
- Implemented types
Constructors
- PostgresDatabase.fromConnection(Connection connection, {bool ownsConnection = false})
-
Wraps an existing
connection.factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- ownsConnection → bool
-
Whether close also closes the wrapped PostgreSQL connection.
final
- ownsPool → bool
-
Whether close also closes the wrapped PostgreSQL pool.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
atomicWrite(
List< BoundSql> statements) → Future<List< SqlWriteResult> > -
Executes transaction-safe DML
statementsas one atomic write batch.override -
close(
) → Future< void> -
Releases resources owned by this database.
override
-
execute(
BoundSql statement) → Future< SqlWriteResult> -
Executes one write
statement.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
query<
T> (BoundSql statement, T decode(SqlRow row)) → Future< List< T> > -
Executes a row-returning
statementand decodes every row in order.override -
toString(
) → String -
A string representation of this object.
inherited
-
transaction<
T> (Future< T> action(SqlExecutor transaction)) → Future<T> -
Runs
actioninside one database transaction.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromPool<
L> (Pool< L> pool, {bool ownsPool = false}) → PostgresDatabase -
Wraps an existing
pool. -
open(
{required String host, int port = 5432, required String database, String? username, String? password, ConnectionSettings settings = const pg.ConnectionSettings()}) → Future< PostgresDatabase> - Opens and owns one PostgreSQL connection.
-
openUrl(
String connectionString) → Future< PostgresDatabase> -
Opens and owns one PostgreSQL connection from
connectionString. -
pool(
{required String host, int port = 5432, required String database, String? username, String? password, PoolSettings settings = const pg.PoolSettings(maxConnectionCount: 4)}) → PostgresDatabase - Creates and owns a lazy PostgreSQL connection pool.
-
poolUrl(
String connectionString) → PostgresDatabase -
Creates and owns a lazy PostgreSQL pool from
connectionString.