angel_orm 2.0.0-dev.14

  • Example
  • Installing
  • Versions
  • 76


Runtime support for Angel's ORM. Includes a clean, database-agnostic query builder and relationship/join support.

For documentation about the ORM, head to the main project repo:


  • Remove obsolete @belongsToMany.


  • Push for consistency with orm_gen @ 2.0.0-dev.


  • Always apply toSql escapes.


  • Remove limit(1) except on getOne


  • Add withFields to compile()


  • Permanent preamble fix


  • Escapes


  • Update toSql
  • Add isTrue and isFalse


  • Add delete, insert and update methods to Query.


  • Add more querying methods.
  • Add preamble to Query.compile.


  • Brought back old-style query builder.
  • Strong-mode updates, revised Join.


  • Renamed ORM to Orm.
  • Orm now requires a database type.


  • Restored all old PostgreSQL-specific annotations. Rather than a smart runtime, having a codegen capable of building ORM's for multiple databases can potentially provide a very fast ORM for everyone.


  • Removed PostgreSQL-specific functionality, so that the ORM can ultimately target all services.
  • Created a better Join model.
  • Created a far better Query model.
  • Removed lib/server.dart


  • Split into angel_orm.dart and server.dart. Prevents DDC failures.


  • Added a @belongsToMany annotation class.
  • Resolved #20. The PostgreSQLConnectionPool keeps track of which connections have been opened now.


  • DateTimeSqlExpressionBuilder will no longer automatically insert quotation marks around names.


  • Corrected a typo that was causing the aforementioned test failures. == becomes =.


  • Added a null-check in lib/src/query.dart#L24 to (hopefully) prevent it from crashing on Travis.


  • Added isIn, isNotIn, isBetween, isNotBetween to SqlExpressionBuilder and its subclasses.
  • Added a dependency on package:meta.


import 'dart:async';

import 'package:angel_model/angel_model.dart';
import 'package:angel_orm/angel_orm.dart';
import 'package:angel_orm/src/query.dart';
import 'package:angel_serialize/angel_serialize.dart';
part 'main.g.dart';
part 'main.serializer.g.dart';

main() async {
  var query = new EmployeeQuery()
    ..orWhere((w) => w.salary.greaterThanOrEqualTo(75000))
    ..join('companies', 'company_id', 'id');

  var richPerson = await query.getOne(new _FakeExecutor());

class _FakeExecutor extends QueryExecutor {
  const _FakeExecutor();

  Future<List<List>> query(String query, [returningFields]) async {
    var now = new;
    print('_FakeExecutor received query: $query');
    return [
      [1, 'Rich', 'Person', 100000.0, now, now]

  Future<T> transaction<T>(FutureOr<T> Function() f) {
    throw new UnsupportedError('Transactions are not supported.');

abstract class _Employee extends Model {
  String get firstName;

  String get lastName;

  double get salary;

class EmployeeQuery extends Query<Employee, EmployeeQueryWhere> {
  final QueryValues values = new MapQueryValues();

  final EmployeeQueryWhere where = new EmployeeQueryWhere();

  String get tableName => 'employees';

  List<String> get fields =>
      ['id', 'first_name', 'last_name', 'salary', 'created_at', 'updated_at'];

  Employee deserialize(List row) {
    return new Employee(
        id: row[0].toString(),
        firstName: row[1] as String,
        lastName: row[2] as String,
        salary: row[3] as double,
        createdAt: row[4] as DateTime,
        updatedAt: row[5] as DateTime);

class EmployeeQueryWhere extends QueryWhere {
  Iterable<SqlExpressionBuilder> get expressionBuilders {
    return [id, firstName, lastName, salary, createdAt, updatedAt];

  final NumericSqlExpressionBuilder<int> id =
      new NumericSqlExpressionBuilder<int>('id');

  final StringSqlExpressionBuilder firstName =
      new StringSqlExpressionBuilder('first_name');

  final StringSqlExpressionBuilder lastName =
      new StringSqlExpressionBuilder('last_name');

  final NumericSqlExpressionBuilder<double> salary =
      new NumericSqlExpressionBuilder<double>('salary');

  final DateTimeSqlExpressionBuilder createdAt =
      new DateTimeSqlExpressionBuilder('created_at');

  final DateTimeSqlExpressionBuilder updatedAt =
      new DateTimeSqlExpressionBuilder('updated_at');

Use this package as a library

1. Depend on it

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

  angel_orm: ^2.0.0-dev.14

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:angel_orm/angel_orm.dart';
Version Uploaded Documentation Archive
2.0.0-dev.14 Dec 8, 2018 Go to the documentation of angel_orm 2.0.0-dev.14 Download angel_orm 2.0.0-dev.14 archive
2.0.0-dev.13 Dec 8, 2018 Go to the documentation of angel_orm 2.0.0-dev.13 Download angel_orm 2.0.0-dev.13 archive
2.0.0-dev.12 Dec 3, 2018 Go to the documentation of angel_orm 2.0.0-dev.12 Download angel_orm 2.0.0-dev.12 archive
2.0.0-dev.11 Dec 3, 2018 Go to the documentation of angel_orm 2.0.0-dev.11 Download angel_orm 2.0.0-dev.11 archive
2.0.0-dev.10 Dec 3, 2018 Go to the documentation of angel_orm 2.0.0-dev.10 Download angel_orm 2.0.0-dev.10 archive
2.0.0-dev.9 Dec 3, 2018 Go to the documentation of angel_orm 2.0.0-dev.9 Download angel_orm 2.0.0-dev.9 archive
2.0.0-dev.8 Dec 3, 2018 Go to the documentation of angel_orm 2.0.0-dev.8 Download angel_orm 2.0.0-dev.8 archive
2.0.0-dev.7 Dec 3, 2018 Go to the documentation of angel_orm 2.0.0-dev.7 Download angel_orm 2.0.0-dev.7 archive
2.0.0-dev.6 Dec 3, 2018 Go to the documentation of angel_orm 2.0.0-dev.6 Download angel_orm 2.0.0-dev.6 archive
2.0.0-dev.5 Dec 1, 2018 Go to the documentation of angel_orm 2.0.0-dev.5 Download angel_orm 2.0.0-dev.5 archive

All 28 versions...

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 Dec 8, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:angel_orm/angel_orm.dart.

Maintenance suggestions

Package is pre-release. (-5 points)

Pre-release versions should be used with caution, their API may change in breaking ways.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.1.2 <3.0.0
charcode ^1.0.0 1.1.2
intl ^0.15.7 0.15.7
meta ^1.0.0 1.1.6
string_scanner ^1.0.0 1.0.4
Transitive dependencies
path 1.6.2
source_span 1.4.1
Dev dependencies
angel_model ^1.0.0
angel_serialize ^2.0.0
angel_serialize_generator ^2.0.0
build_runner ^1.0.0
test ^1.0.0