knex_dart_postgres 0.1.1 copy "knex_dart_postgres: ^0.1.1" to clipboard
knex_dart_postgres: ^0.1.1 copied to clipboard

PostgreSQL driver for knex_dart — connect and execute queries against a PostgreSQL database using the knex_dart query builder.

knex_dart_postgres #

PostgreSQL driver for knex_dart — execute queries against a PostgreSQL database using the knex_dart query builder.

Pub Version License: MIT

Installation #

dependencies:
  knex_dart_postgres: ^0.1.0

Usage #

import 'package:knex_dart_postgres/knex_dart_postgres.dart';

final db = await KnexPostgres.connect(
  host: 'localhost',
  port: 5432,
  database: 'mydb',
  username: 'user',
  password: 'pass',
);

// SELECT
final users = await db.select(
  db('users').where('active', '=', true).orderBy('name').limit(10),
);

// INSERT
await db.insert(
  db('users').insert({'name': 'Alice', 'email': 'alice@example.com'}),
);

// UPDATE
await db.update(
  db('users').where('id', '=', 1).update({'name': 'Bob'}),
);

// DELETE
await db.delete(
  db('users').where('id', '=', 1).delete(),
);

// Schema
await db.executeSchema(
  db.schema.createTable('posts', (t) {
    t.increments('id');
    t.string('title').notNullable();
    t.integer('user_id').references('id').inTable('users');
    t.timestamps();
  }),
);

// Transactions
await db.trx((trx) async {
  await trx.insert(trx('accounts').insert({'balance': 100}));
  await trx.update(trx('accounts').where('id', '=', 1).update({'balance': 0}));
});

await db.destroy();

PostgreSQL-specific features #

  • Named parameter placeholders ($1, $2, ...)
  • RETURNING clause support
  • JSON operators (whereJsonPath, whereJsonSupersetOf, whereJsonSubsetOf)
  • Full-text search (whereFullText with language option)
  • Connection pooling support
  • Nested transactions via savepoints

Documentation #

See also #

0
likes
150
points
190
downloads

Documentation

API reference

Publisher

verified publishermahawarkartikey.in

Weekly Downloads

PostgreSQL driver for knex_dart — connect and execute queries against a PostgreSQL database using the knex_dart query builder.

Repository (GitHub)
View/report issues
Contributing

Topics

#sql #query-builder #database #postgresql #knex

License

MIT (license)

Dependencies

knex_dart, logging, postgres

More

Packages that depend on knex_dart_postgres