angel_orm 2.0.0

  • Example
  • Installing
  • Versions
  • 88

angel_orm #

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:

2.0.0 #

  • Add isNull, isNotNull getters to builders.

2.0.0-dev.24 #

  • Fix a bug that caused syntax errors on ORDER BY.
  • Add pattern to like on string builder. sanitize is optional.
  • Add RawSql.

2.0.0-dev.23 #

  • Add @ManyToMany annotation, which builds many-to-many relations.

2.0.0-dev.22 #

  • compileInsert will explicitly never emit a key not belonging to the associated query.

2.0.0-dev.21 #

  • Add tableName to query

2.0.0-dev.20 #

  • Join updates.

2.0.0-dev.19 #

  • Implement cast-based double support.
  • Finish ListSqlExpressionBuilder.

2.0.0-dev.18 #

  • Add ListSqlExpressionBuilder (still in development).

2.0.0-dev.17 #

  • Add EnumSqlExpressionBuilder.

2.0.0-dev.16 #

  • Add MapSqlExpressionBuilder for JSON/JSONB support.

2.0.0-dev.15 #

  • Remove Column.defaultValue.
  • Deprecate toSql and sanitizeExpression.
  • Refactor builders so that strings are passed through

2.0.0-dev.14 #

  • Remove obsolete @belongsToMany.

2.0.0-dev.13 #

  • Push for consistency with orm_gen @ 2.0.0-dev.

2.0.0-dev.12 #

  • Always apply toSql escapes.

2.0.0-dev.11 #

  • Remove limit(1) except on getOne

2.0.0-dev.10 #

  • Add withFields to compile()

2.0.0-dev.9 #

  • Permanent preamble fix

2.0.0-dev.8 #

  • Escapes

2.0.0-dev.7 #

  • Update toSql
  • Add isTrue and isFalse

2.0.0-dev.6 #

  • Add delete, insert and update methods to Query.

2.0.0-dev.4 #

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

2.0.0-dev.3 #

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

2.0.0-dev.2 #

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

2.0.0-dev.1 #

  • 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.

2.0.0-dev #

  • 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

1.0.0-alpha+10 #

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

1.0.0-alpha+7 #

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

1.0.0-alpha+6 #

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

1.0.0-alpha+5 #

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

1.0.0-alpha+4 #

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

1.0.0-alpha+3 #

  • 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 tableName, String query, Map<String, dynamic> substitutionValues,
      [returningFields]) async {
    var now = new;
        '_FakeExecutor received query: $query and values: $substitutionValues');
    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();

  EmployeeQueryWhere _where;

  EmployeeQuery() {
    _where = new EmployeeQueryWhere(this);

  EmployeeQueryWhere get where => _where;

  String get tableName => 'employees';

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

  EmployeeQueryWhere newWhereClause() => new EmployeeQueryWhere(this);

  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 {
  EmployeeQueryWhere(EmployeeQuery query)
      : id = new NumericSqlExpressionBuilder(query, 'id'),
        firstName = new StringSqlExpressionBuilder(query, 'first_name'),
        lastName = new StringSqlExpressionBuilder(query, 'last_name'),
        salary = new NumericSqlExpressionBuilder(query, 'salary'),
        createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
        updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');

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

  final NumericSqlExpressionBuilder<int> id;

  final StringSqlExpressionBuilder firstName;

  final StringSqlExpressionBuilder lastName;

  final NumericSqlExpressionBuilder<double> salary;

  final DateTimeSqlExpressionBuilder createdAt;

  final DateTimeSqlExpressionBuilder updatedAt;

Use this package as a library

1. Depend on it

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

  angel_orm: ^2.0.0

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 Apr 8, 2019 Go to the documentation of angel_orm 2.0.0 Download angel_orm 2.0.0 archive
2.0.0-dev.24 Apr 4, 2019 Go to the documentation of angel_orm 2.0.0-dev.24 Download angel_orm 2.0.0-dev.24 archive
2.0.0-dev.23 Apr 2, 2019 Go to the documentation of angel_orm 2.0.0-dev.23 Download angel_orm 2.0.0-dev.23 archive
2.0.0-dev.22 Mar 14, 2019 Go to the documentation of angel_orm 2.0.0-dev.22 Download angel_orm 2.0.0-dev.22 archive
2.0.0-dev.21 Feb 13, 2019 Go to the documentation of angel_orm 2.0.0-dev.21 Download angel_orm 2.0.0-dev.21 archive
2.0.0-dev.20 Feb 8, 2019 Go to the documentation of angel_orm 2.0.0-dev.20 Download angel_orm 2.0.0-dev.20 archive
2.0.0-dev.19 Jan 27, 2019 Go to the documentation of angel_orm 2.0.0-dev.19 Download angel_orm 2.0.0-dev.19 archive
2.0.0-dev.18 Jan 24, 2019 Go to the documentation of angel_orm 2.0.0-dev.18 Download angel_orm 2.0.0-dev.18 archive
2.0.0-dev.17 Jan 23, 2019 Go to the documentation of angel_orm 2.0.0-dev.17 Download angel_orm 2.0.0-dev.17 archive
2.0.0-dev.16 Jan 23, 2019 Go to the documentation of angel_orm 2.0.0-dev.16 Download angel_orm 2.0.0-dev.16 archive

All 39 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 Apr 24, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14


Detected platforms: Flutter, web, other

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


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.8
meta ^1.0.0 1.1.7
string_scanner ^1.0.0 1.0.4
Transitive dependencies
path 1.6.2
source_span 1.5.5
term_glyph 1.1.0
Dev dependencies
angel_model ^1.0.0
angel_serialize ^2.0.0
angel_serialize_generator ^2.0.0
build_runner ^1.0.0
pedantic ^1.0.0
test ^1.0.0