jaguar_query_postgres 2.2.6

  • Readme
  • Changelog
  • Installing
  • 73

jaguar_query_postgresql #

postgresql adapter for jaguar_orm

Usage #

A simple usage example:

import 'dart:async';
import 'package:jaguar_orm_postgresql/jaguar_orm_postgresql.dart';

// The model
class Post {

  Post.make(, this.msg,;

  int id;

  String msg;

  String author;

  String toString() => '$id $msg $author';

/// The adapter
PgAdapter _adapter =
    new PgAdapter('postgres://postgres:dart_jaguar@localhost/postgres');

/// The bean
class PostBean {
  /// Field DSL for id column
  final IntField id = new IntField('_id');

  /// Field DSL for msg column
  final StrField msg = new StrField('msg');

  /// Field DSL for author column
  final StrField author = new StrField('author');

  /// Table name for the model this bean manages
  String get tableName => 'posts';

  /// Inserts a new post into table
  Future insert(Post post) async {
    InsertStatement inserter = new InsertStatement()..into(tableName);


    await _adapter.insert(inserter);

  /// Updates a post
  Future update(int id, String author) async {
    UpdateStatement updater = new UpdateStatement()..into(tableName);


    await _adapter.update(updater);

  /// Finds one post by [id]
  Future<Post> findOne(int id) async {
    FindStatement updater = new FindStatement()..from(tableName);


    Map map = await _adapter.findOne(updater);

    Post post = new Post(); = map['_id'];
    post.msg = map['msg']; = map['author'];

    return post;

  /// Finds all posts
  Future<List<Post>> findAll() async {
    FindStatement finder = new FindStatement()..from(tableName);

    List<Map> maps = await (await _adapter.find(finder)).toList();

    List<Post> posts = new List<Post>();

    for(Map map in maps) {
      Post post = new Post(); = map['_id'];
      post.msg = map['msg']; = map['author'];


    return posts;

  /// Deletes a post by [id]
  Future delete(int id) async {
    DeleteStatement deleter = new DeleteStatement()..from(tableName);


    await _adapter.delete(deleter);

  /// Deletes all posts
  Future deleteAll() async {
    DeleteStatement deleter = new DeleteStatement()..from(tableName);

    await _adapter.delete(deleter);

main() async {
  // Connect
  await _adapter.connect();

  PostBean bean = new PostBean();

  // Delete all
  await bean.deleteAll();

  // Insert some posts
  await bean.insert(new Post.make(1, 'Whatever 1', 'mark'));
  await bean.insert(new Post.make(2, 'Whatever 2', 'bob'));

  // Find one post
  Post post = await bean.findOne(1);

  // Find all posts
  List<Post> posts = await bean.findAll();

  // Update a post
  await bean.update(1, 'rowling');

  // Check that the post is updated
  post = await bean.findOne(1);

  // Delete some posts
  await bean.delete(1);
  await bean.delete(2);

  // Find a post when none exists
  try {
    post = await bean.findOne(1);
  } on JaguarOrmException catch(e) {

  // Close connection
  await _adapter.close();

Changelog #

2.2.6 #

  • Alter statement

2.1.5 #

  • Conforming to new Adapter interface

2.1.3 #

  • Added parseValue to Adapter

2.1.1 #

  • Dart2 support

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  jaguar_query_postgres: ^2.2.6

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:jaguar_query_postgres/jaguar_query_postgres.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21


Detected platforms: Flutter, other

Primary library: package:jaguar_query_postgres/jaguar_query_postgres.dart with components: io.

Health suggestions

Fix lib/src/adapter.dart. (-2.48 points)

Analysis of lib/src/adapter.dart reported 5 hints:

line 24 col 47: Use = to separate a named parameter from its default value.

line 24 col 71: Use = to separate a named parameter from its default value.

line 37 col 7: DO use curly braces for all flow control structures.

line 57 col 9: Use isEmpty instead of length

line 62 col 52: DO use curly braces for all flow control structures.

Fix lib/src/compose/compose.dart. (-1.49 points)

Analysis of lib/src/compose/compose.dart reported 3 hints:

line 72 col 7: Use isEmpty instead of length

line 91 col 7: Use isNotEmpty instead of length

line 106 col 7: Use isNotEmpty instead of length

Fix lib/src/compose/create.dart. (-0.50 points)

Analysis of lib/src/compose/create.dart reported 1 hint:

line 70 col 7: Use isNotEmpty instead of length

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (postgres).

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and jaguar_query_postgres.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
jaguar_query ^2.2.6 2.2.8
path ^1.6.2 1.6.4
postgres ^1.0.0 1.0.2 2.0.0-dev1.0
Transitive dependencies
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
meta 1.1.7
typed_data 1.1.6
Dev dependencies
test ^1.3.0