💧 raindrop_postgres
The Postgres driver for raindrop, built
on postgres.
Usage
Declare tables with postgresTable, then hand a PostgresDelegate an open
Connection (or a Pool):
import 'package:postgres/postgres.dart';
import 'package:raindrop/raindrop.dart';
import 'package:raindrop_postgres/raindrop_postgres.dart';
final users = postgresTable('users', UserSchema.new);
void main() async {
final connection = await Connection.open(
Endpoint(host: 'localhost', database: 'postgres', username: 'postgres'),
);
final db = Raindrop(PostgresDelegate(connection));
final [user] = await db.insert(into: users).values([
const User(name: 'Alex'),
]).returning();
}
The connection is yours: the driver does not pool, retry, or reconnect.
Beyond the core DSL
Everything in the core raindrop DSL works
unchanged. On top of it this driver adds upserts:
await db.insert(into: users).values([user])
.onConflict([users.email])
.doUpdate([users.age.to(excluded(users.age))]);
// INSERT ... ON CONFLICT ("email") DO UPDATE SET "age" = "excluded"."age"
returning()on inserts, updates and deletes yields the affected rows.now()andgenRandomUuid()evaluate in the database.- Column types beyond the core set:
boolean,dateTime(TIMESTAMP),bigInt(NUMERIC),textArray(TEXT[]) andblob(BYTEA). %works onbigIntcolumns, computed overNUMERIC.