drift/extras/drift_postgres
Simon Binder 0e44b22b8f
Add stability node to drift_postgres
2023-10-20 11:58:25 +02:00
..
example Support custom types in postgres backend 2023-10-07 18:08:18 +02:00
lib Add `date` and `timestamp` types for postgres 2023-10-12 00:03:01 +02:00
test Add `date` and `timestamp` types for postgres 2023-10-12 00:03:01 +02:00
.gitignore PostgreSQL support (#1507) 2021-11-11 14:40:41 +01:00
README.md Add stability node to drift_postgres 2023-10-20 11:58:25 +02:00
analysis_options.yaml Fix lints and warnings added in Dart 3.0 2023-05-12 22:42:21 +02:00
pubspec.yaml Add documentation page on postgres 2023-10-10 22:41:01 +02:00

README.md

package:drift_postgres extends drift to support talking to PostgreSQL databases by using the postgres package.

This package is currently in beta. It uses preview APIs from the postgres packages, which may require this package to be updated if there are breaking changes in that package. Once these APIs from postgres are stabilized, a stable version of drift_postgres will be released as well.

Using this

For general notes on using drift, see this guide.

To use drift_postgres, add this to your pubspec.yaml

dependencies:
  drift: "$latest version"
  drift_postgres: ^0.1.0

To connect your drift database class to postgres, use a PgDatabase from package:drift_postgres/postgres.dart:

final database = AppDatabase(PgDatabase(
  endpoint: PgEndpoint(
    host: 'localhost',
    database: 'postgres',
    username: 'postgres',
    password: 'postgres',
  ),
));

Running tests

To test this package, first run

docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres

It can then be tested with dart test.