2018-08-24 13:42:09 +00:00
|
|
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
|
|
|
|
part of angel_orm_generator.test.models.tree;
|
|
|
|
|
2018-12-08 04:13:49 +00:00
|
|
|
// **************************************************************************
|
|
|
|
// OrmGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
class TreeQuery extends Query<Tree, TreeQueryWhere> {
|
|
|
|
TreeQuery() {}
|
|
|
|
|
|
|
|
@override
|
|
|
|
final TreeQueryValues values = new TreeQueryValues();
|
|
|
|
|
|
|
|
@override
|
|
|
|
final TreeQueryWhere where = new TreeQueryWhere();
|
|
|
|
|
|
|
|
@override
|
|
|
|
get tableName {
|
|
|
|
return 'trees';
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
get fields {
|
|
|
|
return const ['id', 'rings', 'created_at', 'updated_at'];
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
TreeQueryWhere newWhereClause() {
|
|
|
|
return new TreeQueryWhere();
|
|
|
|
}
|
|
|
|
|
|
|
|
static Tree parseRow(List row) {
|
|
|
|
if (row.every((x) => x == null)) return null;
|
|
|
|
var model = new Tree(
|
|
|
|
id: row[0].toString(),
|
|
|
|
rings: (row[1] as int),
|
|
|
|
createdAt: (row[2] as DateTime),
|
|
|
|
updatedAt: (row[3] as DateTime));
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
deserialize(List row) {
|
|
|
|
return parseRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
insert(executor) {
|
|
|
|
return executor.transaction(() async {
|
|
|
|
var result = await super.insert(executor);
|
|
|
|
where.id.equals(int.parse(result.id));
|
|
|
|
result = await getOne(executor);
|
|
|
|
result = await fetchLinked(result, executor);
|
|
|
|
return result;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Tree> fetchLinked(Tree model, QueryExecutor executor) async {
|
|
|
|
return model.copyWith(
|
|
|
|
fruits: await (new FruitQuery()
|
|
|
|
..where.treeId.equals(int.parse(model.id)))
|
|
|
|
.get(executor));
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
get(QueryExecutor executor) {
|
|
|
|
return executor.transaction(() async {
|
|
|
|
var result = await super.get(executor);
|
|
|
|
return await Future.wait(result.map((m) => fetchLinked(m, executor)));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
update(QueryExecutor executor) {
|
|
|
|
return executor.transaction(() async {
|
|
|
|
var result = await super.update(executor);
|
|
|
|
return await Future.wait(result.map((m) => fetchLinked(m, executor)));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
delete(QueryExecutor executor) {
|
|
|
|
return executor.transaction(() async {
|
|
|
|
var result = await super.delete(executor);
|
|
|
|
return await Future.wait(result.map((m) => fetchLinked(m, executor)));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TreeQueryWhere extends QueryWhere {
|
|
|
|
final NumericSqlExpressionBuilder<int> id =
|
|
|
|
new NumericSqlExpressionBuilder<int>('id');
|
|
|
|
|
|
|
|
final NumericSqlExpressionBuilder<int> rings =
|
|
|
|
new NumericSqlExpressionBuilder<int>('rings');
|
|
|
|
|
|
|
|
final DateTimeSqlExpressionBuilder createdAt =
|
|
|
|
new DateTimeSqlExpressionBuilder('created_at');
|
|
|
|
|
|
|
|
final DateTimeSqlExpressionBuilder updatedAt =
|
|
|
|
new DateTimeSqlExpressionBuilder('updated_at');
|
|
|
|
|
|
|
|
@override
|
|
|
|
get expressionBuilders {
|
|
|
|
return [id, rings, createdAt, updatedAt];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TreeQueryValues extends MapQueryValues {
|
|
|
|
int get id {
|
|
|
|
return (values['id'] as int);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set id(int value) => values['id'] = value;
|
|
|
|
int get rings {
|
|
|
|
return (values['rings'] as int);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set rings(int value) => values['rings'] = value;
|
|
|
|
DateTime get createdAt {
|
|
|
|
return (values['created_at'] as DateTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set createdAt(DateTime value) => values['created_at'] = value;
|
|
|
|
DateTime get updatedAt {
|
|
|
|
return (values['updated_at'] as DateTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
|
|
|
void copyFrom(Tree model) {
|
|
|
|
values.addAll({
|
|
|
|
'rings': model.rings,
|
|
|
|
'created_at': model.createdAt,
|
|
|
|
'updated_at': model.updatedAt
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-24 13:42:09 +00:00
|
|
|
// **************************************************************************
|
|
|
|
// JsonModelGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
@generatedSerializable
|
|
|
|
class Tree extends _Tree {
|
|
|
|
Tree(
|
2018-12-03 13:41:14 +00:00
|
|
|
{this.id, this.rings, List<Fruit> fruits, this.createdAt, this.updatedAt})
|
2018-08-24 13:42:09 +00:00
|
|
|
: this.fruits = new List.unmodifiable(fruits ?? []);
|
|
|
|
|
|
|
|
@override
|
|
|
|
final String id;
|
|
|
|
|
|
|
|
@override
|
|
|
|
final int rings;
|
|
|
|
|
|
|
|
@override
|
2018-12-03 13:41:14 +00:00
|
|
|
final List<Fruit> fruits;
|
2018-08-24 13:42:09 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
final DateTime createdAt;
|
|
|
|
|
|
|
|
@override
|
|
|
|
final DateTime updatedAt;
|
|
|
|
|
|
|
|
Tree copyWith(
|
|
|
|
{String id,
|
|
|
|
int rings,
|
2018-12-03 13:41:14 +00:00
|
|
|
List<Fruit> fruits,
|
2018-08-24 13:42:09 +00:00
|
|
|
DateTime createdAt,
|
|
|
|
DateTime updatedAt}) {
|
|
|
|
return new Tree(
|
|
|
|
id: id ?? this.id,
|
|
|
|
rings: rings ?? this.rings,
|
|
|
|
fruits: fruits ?? this.fruits,
|
|
|
|
createdAt: createdAt ?? this.createdAt,
|
|
|
|
updatedAt: updatedAt ?? this.updatedAt);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator ==(other) {
|
|
|
|
return other is _Tree &&
|
|
|
|
other.id == id &&
|
|
|
|
other.rings == rings &&
|
2018-12-03 13:41:14 +00:00
|
|
|
const ListEquality<Fruit>(const DefaultEquality<Fruit>())
|
2018-08-24 13:42:09 +00:00
|
|
|
.equals(other.fruits, fruits) &&
|
|
|
|
other.createdAt == createdAt &&
|
|
|
|
other.updatedAt == updatedAt;
|
|
|
|
}
|
|
|
|
|
2018-12-01 19:03:43 +00:00
|
|
|
@override
|
|
|
|
int get hashCode {
|
|
|
|
return hashObjects([id, rings, fruits, createdAt, updatedAt]);
|
|
|
|
}
|
|
|
|
|
2018-08-24 13:42:09 +00:00
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
return TreeSerializer.toMap(this);
|
|
|
|
}
|
|
|
|
}
|