Source code generators for Angel's ORM. This package can generate:
For documentation about the ORM, head to the main project repo: https://github.com/angel-dart/orm
double
support.ListSqlExpressionBuilder
.package:angel_orm@2.0.0-dev.15
.DateTime
is now CAST
on insertion and update operations.Implemented @hasOne
, with tests. Still missing @hasMany
.
belongsToMany
will likely be scrapped.
belongsTo
relationships. Still missing hasOne
, hasMany
, belongsToMany
.insertX
and updateX
now use rc.camelCase
, instead of rc.snakeCase
.limit
and offset
properties to XQuery
.or
method (it now takes an XQueryWhere
), and removed and
and not
.sortAscending
and sortDescending
to XQuery
.delete
now uses toSql
from XQuery
.XQuery
now supports union
and unionAll
.example/main.dart
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()
..where.firstName.equals('Rich')
..where.lastName.equals('Person')
..orWhere((w) => w.salary.greaterThanOrEqualTo(75000))
..join('companies', 'company_id', 'id');
var richPerson = await query.getOne(new _FakeExecutor());
print(richPerson.toJson());
}
class _FakeExecutor extends QueryExecutor {
const _FakeExecutor();
@override
Future<List<List>> query(
String query, Map<String, dynamic> substitutionValues,
[returningFields]) async {
var now = new DateTime.now();
print(
'_FakeExecutor received query: $query and values: $substitutionValues');
return [
[1, 'Rich', 'Person', 100000.0, now, now]
];
}
@override
Future<T> transaction<T>(FutureOr<T> Function() f) {
throw new UnsupportedError('Transactions are not supported.');
}
}
@orm
@serializable
abstract class _Employee extends Model {
String get firstName;
String get lastName;
double get salary;
}
class EmployeeQuery extends Query<Employee, EmployeeQueryWhere> {
@override
final QueryValues values = new MapQueryValues();
EmployeeQueryWhere _where;
EmployeeQuery() {
_where = new EmployeeQueryWhere(this);
}
@override
EmployeeQueryWhere get where => _where;
@override
String get tableName => 'employees';
@override
List<String> get fields =>
['id', 'first_name', 'last_name', 'salary', 'created_at', 'updated_at'];
@override
EmployeeQueryWhere newWhereClause() => new EmployeeQueryWhere(this);
@override
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');
@override
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;
}
Add this to your package's pubspec.yaml file:
dependencies:
angel_orm_generator: ^2.0.0-dev.6
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.
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 |
|
|
2.0.0-dev.5 | Jan 27, 2019 |
|
|
2.0.0-dev.4 | Jan 24, 2019 |
|
|
2.0.0-dev.3 | Jan 23, 2019 |
|
|
2.0.0-dev.2 | Dec 31, 2018 |
|
|
2.0.0-dev.1 | Dec 9, 2018 |
|
|
2.0.0-dev | Dec 8, 2018 |
|
|
1.0.0-alpha+6 | Dec 8, 2017 |
|
|
1.0.0-alpha+5 | Nov 20, 2017 |
|
|
1.0.0-alpha+4 | Sep 15, 2017 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
42
|
Health:
Code health derived from static analysis.
[more]
|
98
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
0
|
Overall:
Weighted score of the above.
[more]
|
50
|
We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: other
Primary library:
package:angel_orm_generator/angel_orm_generator.dart
with components:io
,build
,mirrors
.
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.
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 | ||
angel_migration | |||
build_runner | ^1.0.0 | ||
collection | ^1.0.0 | 1.14.11 | |
postgres | ^1.0.0 | ||
test | ^1.0.0 |