sql_query_builder 1.0.12 copy "sql_query_builder: ^1.0.12" to clipboard
sql_query_builder: ^1.0.12 copied to clipboard

discontinuedreplaced by: dox_query_builder
SDKDart
outdated

PostgresSQL query builder, Support Model, Where, orWhere, Find, Join, softDeletes, Debugging and many mores.

example/example.md

Dart SQL Query Builder #

Documentation #

Example Usage #

import 'package:postgres/postgres.dart';
import 'package:sql_query_builder/sql_query_builder.dart';

class Actor extends Model {
  @override
  String get primaryKey => 'id';

  @Column()
  int? id;

  @Column(name: 'name')
  String? actorName;

  @Column()
  int? age;

  @Column(name: 'created_at')
  DateTime? createdAt;

  @Column(name: 'updated_at')
  DateTime? updatedAt;
}

void main() async {
  // create database connection and open
  PostgreSQLConnection db = PostgreSQLConnection(
    'localhost',
    5432,
    'postgres',
    username: 'admin',
    password: 'password',
  );
  await db.open();

  // initialize SqlQueryBuilder, only once at main function
  SqlQueryBuilder.initialize(database: db, debug: true);

  // and finally use model from anywhere in the project.
  Actor actor = Actor();
  actor.actorName = 'John Wick';
  actor.age = 60;
  await actor.save();

  actor.actorName = "Tom Cruise";
  await actor.save(); // save again

  print(actor.id);

  Actor result = await Actor().where('name', 'Tom Cruise').get();
  print(result.age);
}
10
likes
140
points
65
downloads

Publisher

verified publisherzinkyawkyaw.dev

Weekly Downloads

PostgresSQL query builder, Support Model, Where, orWhere, Find, Join, softDeletes, Debugging and many mores.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

postgres

More

Packages that depend on sql_query_builder