postgres_builder 2.0.0
postgres_builder: ^2.0.0 copied to clipboard
A tool designed to make writing PostgreSQL statements easier without writing them by hand.
example/lib/main.dart
// ignore_for_file: unused_local_variable
import 'package:postgres_builder/postgres_builder.dart';
Future<void> main() async {
final builder = PgPoolPostgresBuilder(
endpoint: Endpoint(
host: 'localhost',
database: 'postgres',
),
);
final users = await builder.mappedQuery(
const Select(
[
Column.star(),
],
from: 'users',
),
fromJson: User.fromJson,
);
// use users
}
class User {
const User({required this.name});
factory User.fromJson(Map<String, dynamic> json) =>
User(name: json['name'] as String);
final String name;
}