Drift Postgres | Coderz Repository

drift_postgres

Last updated:

0 purchases

drift_postgres Image
drift_postgres Images

Free

Languages

Categories

Add to Cart

Description:

drift postgres

package:drift_postgres extends drift to support
talking to PostgreSQL databases by using the postgres package.
Using this #
For general notes on using drift, see this guide.
Detailed docs on getting started with drift_postgres are available here.
To use drift_postgres, add this to your pubspec.yaml
dependencies:
drift: "$latest version"
drift_postgres: ^0.1.0
copied to clipboard
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',
),
));
copied to clipboard
Also, consider adding builder options to make drift generate postgres-specific code:
# build.yaml
targets:
$default:
builders:
drift_dev:
options:
sql:
dialects:
- sqlite # remove this line if you only need postgres
- postgres
copied to clipboard
Running tests #
To test this package, first run
docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres
copied to clipboard
It can then be tested with dart test -j 1 (concurrency needs to be disabled since tests are using the same database).

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.