angel_orm_generator 2.0.0-dev.6

  • Example
  • Installing
  • Versions
  • 50

angel_orm_generator #

Source code generators for Angel's ORM. This package can generate:

  • A strongly-typed ORM
  • SQL migration scripts

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

2.0.0-dev.6 #

  • Fix bug where an extra field would be inserted into joins and botch the result.
  • Narrow analyzer dependency.

2.0.0-dev.5 #

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

2.0.0-dev.4 #

  • List generation support.

2.0.0-dev.3 #

  • Add JSON/JSONB support for Maps.

2.0.0-dev.2 #

  • Changes to work with package:angel_orm@2.0.0-dev.15.

2.0.0-dev.1 #

  • Generate migration files.

2.0.0-dev #

  • Dart 2 updates, and more.

1.0.0-alpha+6 #

  • DateTime is now CAST on insertion and update operations.

1.0.0-alpha+3 #

Implemented @hasOne, with tests. Still missing @hasMany. belongsToMany will likely be scrapped.

1.0.0-alpha+2 #

  • Added support for belongsTo relationships. Still missing hasOne, hasMany, belongsToMany.

1.0.0-alpha+1 #

  • Closed #12. insertX and updateX now use rc.camelCase, instead of rc.snakeCase.
  • Closed #13. Added limit and offset properties to XQuery.
  • Closed #14. Refined the or method (it now takes an XQueryWhere), and removed and and not.
  • Closed #16. Added sortAscending and sortDescending to XQuery.
  • Closed #17. delete now uses toSql from XQuery.
  • Closed #18. XQuery now supports union and unionAll.


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, 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_generator: ^2.0.0-dev.6

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub 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_generator/angel_orm_generator.dart';
Version Uploaded Documentation Archive
2.0.0-dev.6 Feb 8, 2019 Go to the documentation of angel_orm_generator 2.0.0-dev.6 Download angel_orm_generator 2.0.0-dev.6 archive
2.0.0-dev.5 Jan 27, 2019 Go to the documentation of angel_orm_generator 2.0.0-dev.5 Download angel_orm_generator 2.0.0-dev.5 archive
2.0.0-dev.4 Jan 24, 2019 Go to the documentation of angel_orm_generator 2.0.0-dev.4 Download angel_orm_generator 2.0.0-dev.4 archive
2.0.0-dev.3 Jan 23, 2019 Go to the documentation of angel_orm_generator 2.0.0-dev.3 Download angel_orm_generator 2.0.0-dev.3 archive
2.0.0-dev.2 Dec 31, 2018 Go to the documentation of angel_orm_generator 2.0.0-dev.2 Download angel_orm_generator 2.0.0-dev.2 archive
2.0.0-dev.1 Dec 9, 2018 Go to the documentation of angel_orm_generator 2.0.0-dev.1 Download angel_orm_generator 2.0.0-dev.1 archive
2.0.0-dev Dec 8, 2018 Go to the documentation of angel_orm_generator 2.0.0-dev Download angel_orm_generator 2.0.0-dev archive
1.0.0-alpha+6 Dec 8, 2017 Go to the documentation of angel_orm_generator 1.0.0-alpha+6 Download angel_orm_generator 1.0.0-alpha+6 archive
1.0.0-alpha+5 Nov 20, 2017 Go to the documentation of angel_orm_generator 1.0.0-alpha+5 Download angel_orm_generator 1.0.0-alpha+5 archive
1.0.0-alpha+4 Sep 15, 2017 Go to the documentation of angel_orm_generator 1.0.0-alpha+4 Download angel_orm_generator 1.0.0-alpha+4 archive

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

  • Dart: 2.1.0
  • pana: 0.12.13+1


Detected platforms: other

Primary library: package:angel_orm_generator/angel_orm_generator.dart with components: io, build, mirrors.

Health suggestions

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

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

line 314 col 20: Dead code.

line 372 col 11: Dead code.

line 394 col 30: Dead code.

Fix lib/src/migration_generator.dart. (-0.50 points)

Analysis of lib/src/migration_generator.dart reported 1 hint:

line 28 col 52: Use = to separate a named parameter from its default value.

Fix lib/src/orm_build_context.dart. (-0.50 points)

Analysis of lib/src/orm_build_context.dart reported 1 hint:

line 30 col 22: Use = to separate a named parameter from its default value.

Maintenance issues and suggestions

Prefer published dependencies. (-100 points)

The source code in a git repository is mutable and could disappear.

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: inflection.

Package is pre-release. (-5 points)

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


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
analyzer >=0.27.1 <0.35.0 0.34.3 0.35.1
angel_model ^1.0.0 1.0.1
angel_orm ^2.0.0-dev 2.0.0-dev.21
angel_serialize ^2.0.0 2.2.2+1
angel_serialize_generator ^2.0.0 2.4.1+1
build >=0.12.0 <2.0.0 1.1.0 1.1.1
build_config ^0.3.0 0.3.1+4
code_builder ^3.0.0 3.2.0
dart_style ^1.0.0 1.2.3
inflection 0.4.1
meta ^1.0.0 1.1.7
path ^1.0.0 1.6.2
recase ^2.0.0 2.0.1
source_gen ^0.9.0 0.9.4+1
Transitive dependencies
args 1.5.1
async 2.0.8
built_collection 4.1.0
built_value 6.3.0
charcode 1.1.2
code_buffer 1.0.1
convert 2.1.1
crypto 2.0.6
csslib 0.14.6
fixnum 0.10.9
front_end 0.1.9+1 0.1.11
glob 1.1.7
html 0.13.3+3
intl 0.15.7
json_annotation 2.0.0
kernel 0.3.9+1 0.3.11
logging 0.11.3+2
matcher 0.12.4
package_config 1.0.5
plugin 0.2.0+3
pub_semver 1.4.2
pubspec_parse 0.1.4
quiver 2.0.1
quiver_hashcode 2.0.0
source_span 1.5.4
stack_trace 1.9.3
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
utf 0.9.0+5
watcher 0.9.7+10
yaml 2.1.15
Dev dependencies
angel_framework ^2.0.0-alpha
build_runner ^1.0.0
collection ^1.0.0 1.14.11
postgres ^1.0.0
test ^1.0.0