2018-08-24 13:42:09 +00:00
|
|
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
|
|
|
|
part of angel_orm_generator.test.models.leg;
|
|
|
|
|
2018-12-09 17:44:16 +00:00
|
|
|
// **************************************************************************
|
|
|
|
// MigrationGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
class LegMigration extends Migration {
|
|
|
|
@override
|
|
|
|
up(Schema schema) {
|
|
|
|
schema.create('legs', (table) {
|
|
|
|
table.serial('id')..primaryKey();
|
|
|
|
table.varChar('name');
|
|
|
|
table.timeStamp('created_at');
|
|
|
|
table.timeStamp('updated_at');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
down(Schema schema) {
|
|
|
|
schema.drop('legs');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-03 23:13:11 +00:00
|
|
|
// **************************************************************************
|
|
|
|
// OrmGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
class LegQuery extends Query<Leg, LegQueryWhere> {
|
2018-12-08 02:57:09 +00:00
|
|
|
LegQuery() {
|
2018-12-31 12:22:05 +00:00
|
|
|
_where = new LegQueryWhere(this);
|
2018-12-08 02:57:09 +00:00
|
|
|
leftJoin('feet', 'id', 'leg_id', additionalFields: const [
|
|
|
|
'leg_id',
|
|
|
|
'n_toes',
|
|
|
|
'created_at',
|
|
|
|
'updated_at'
|
|
|
|
]);
|
|
|
|
}
|
2018-12-08 02:03:03 +00:00
|
|
|
|
2018-12-03 23:13:11 +00:00
|
|
|
@override
|
|
|
|
final LegQueryValues values = new LegQueryValues();
|
|
|
|
|
2018-12-31 12:22:05 +00:00
|
|
|
LegQueryWhere _where;
|
2018-12-03 23:13:11 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
get tableName {
|
|
|
|
return 'legs';
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
get fields {
|
|
|
|
return const ['id', 'name', 'created_at', 'updated_at'];
|
|
|
|
}
|
|
|
|
|
2018-12-31 12:22:05 +00:00
|
|
|
@override
|
|
|
|
LegQueryWhere get where {
|
|
|
|
return _where;
|
|
|
|
}
|
|
|
|
|
2018-12-03 23:13:11 +00:00
|
|
|
@override
|
|
|
|
LegQueryWhere newWhereClause() {
|
2018-12-31 12:22:05 +00:00
|
|
|
return new LegQueryWhere(this);
|
2018-12-03 23:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Leg parseRow(List row) {
|
2018-12-08 02:57:09 +00:00
|
|
|
if (row.every((x) => x == null)) return null;
|
2018-12-03 23:13:11 +00:00
|
|
|
var model = new Leg(
|
|
|
|
id: row[0].toString(),
|
|
|
|
name: (row[1] as String),
|
|
|
|
createdAt: (row[2] as DateTime),
|
|
|
|
updatedAt: (row[3] as DateTime));
|
|
|
|
if (row.length > 4) {
|
|
|
|
model = model.copyWith(foot: FootQuery.parseRow(row.skip(4).toList()));
|
|
|
|
}
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
deserialize(List row) {
|
|
|
|
return parseRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2018-12-08 02:03:03 +00:00
|
|
|
insert(executor) {
|
|
|
|
return executor.transaction(() async {
|
|
|
|
var result = await super.insert(executor);
|
|
|
|
where.id.equals(int.parse(result.id));
|
|
|
|
result = await getOne(executor);
|
|
|
|
return result;
|
|
|
|
});
|
2018-12-03 23:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LegQueryWhere extends QueryWhere {
|
2018-12-31 12:22:05 +00:00
|
|
|
LegQueryWhere(LegQuery query)
|
|
|
|
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
|
|
|
name = new StringSqlExpressionBuilder(query, 'name'),
|
|
|
|
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
|
|
|
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
|
|
|
|
|
|
|
final NumericSqlExpressionBuilder<int> id;
|
2018-12-03 23:13:11 +00:00
|
|
|
|
2018-12-31 12:22:05 +00:00
|
|
|
final StringSqlExpressionBuilder name;
|
2018-12-03 23:13:11 +00:00
|
|
|
|
2018-12-31 12:22:05 +00:00
|
|
|
final DateTimeSqlExpressionBuilder createdAt;
|
2018-12-03 23:13:11 +00:00
|
|
|
|
2018-12-31 12:22:05 +00:00
|
|
|
final DateTimeSqlExpressionBuilder updatedAt;
|
2018-12-03 23:13:11 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
get expressionBuilders {
|
|
|
|
return [id, name, createdAt, updatedAt];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LegQueryValues extends MapQueryValues {
|
|
|
|
int get id {
|
|
|
|
return (values['id'] as int);
|
|
|
|
}
|
|
|
|
|
2018-12-31 12:22:05 +00:00
|
|
|
set id(int value) => values['id'] = value;
|
2018-12-03 23:13:11 +00:00
|
|
|
String get name {
|
|
|
|
return (values['name'] as String);
|
|
|
|
}
|
|
|
|
|
2018-12-31 12:22:05 +00:00
|
|
|
set name(String value) => values['name'] = value;
|
2018-12-03 23:13:11 +00:00
|
|
|
DateTime get createdAt {
|
|
|
|
return (values['created_at'] as DateTime);
|
|
|
|
}
|
|
|
|
|
2018-12-31 12:22:05 +00:00
|
|
|
set createdAt(DateTime value) => values['created_at'] = value;
|
2018-12-03 23:13:11 +00:00
|
|
|
DateTime get updatedAt {
|
|
|
|
return (values['updated_at'] as DateTime);
|
|
|
|
}
|
|
|
|
|
2018-12-31 12:22:05 +00:00
|
|
|
set updatedAt(DateTime value) => values['updated_at'] = value;
|
2018-12-03 23:13:11 +00:00
|
|
|
void copyFrom(Leg model) {
|
|
|
|
values.addAll({
|
|
|
|
'name': model.name,
|
|
|
|
'created_at': model.createdAt,
|
|
|
|
'updated_at': model.updatedAt
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-24 13:42:09 +00:00
|
|
|
// **************************************************************************
|
|
|
|
// JsonModelGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
@generatedSerializable
|
|
|
|
class Leg extends _Leg {
|
|
|
|
Leg({this.id, this.foot, this.name, this.createdAt, this.updatedAt});
|
|
|
|
|
|
|
|
@override
|
|
|
|
final String id;
|
|
|
|
|
|
|
|
@override
|
2018-12-03 13:41:14 +00:00
|
|
|
final Foot foot;
|
2018-08-24 13:42:09 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
final String name;
|
|
|
|
|
|
|
|
@override
|
|
|
|
final DateTime createdAt;
|
|
|
|
|
|
|
|
@override
|
|
|
|
final DateTime updatedAt;
|
|
|
|
|
|
|
|
Leg copyWith(
|
|
|
|
{String id,
|
2018-12-03 13:41:14 +00:00
|
|
|
Foot foot,
|
2018-08-24 13:42:09 +00:00
|
|
|
String name,
|
|
|
|
DateTime createdAt,
|
|
|
|
DateTime updatedAt}) {
|
|
|
|
return new Leg(
|
|
|
|
id: id ?? this.id,
|
|
|
|
foot: foot ?? this.foot,
|
|
|
|
name: name ?? this.name,
|
|
|
|
createdAt: createdAt ?? this.createdAt,
|
|
|
|
updatedAt: updatedAt ?? this.updatedAt);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator ==(other) {
|
|
|
|
return other is _Leg &&
|
|
|
|
other.id == id &&
|
|
|
|
other.foot == foot &&
|
|
|
|
other.name == name &&
|
|
|
|
other.createdAt == createdAt &&
|
|
|
|
other.updatedAt == updatedAt;
|
|
|
|
}
|
|
|
|
|
2018-12-01 19:03:43 +00:00
|
|
|
@override
|
|
|
|
int get hashCode {
|
|
|
|
return hashObjects([id, foot, name, createdAt, updatedAt]);
|
|
|
|
}
|
|
|
|
|
2018-08-24 13:42:09 +00:00
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
return LegSerializer.toMap(this);
|
|
|
|
}
|
|
|
|
}
|
2018-12-08 21:00:31 +00:00
|
|
|
|
|
|
|
// **************************************************************************
|
|
|
|
// SerializerGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
abstract class LegSerializer {
|
|
|
|
static Leg fromMap(Map map) {
|
|
|
|
return new Leg(
|
|
|
|
id: map['id'] as String,
|
|
|
|
foot: map['foot'] != null
|
|
|
|
? FootSerializer.fromMap(map['foot'] as Map)
|
|
|
|
: null,
|
|
|
|
name: map['name'] as String,
|
|
|
|
createdAt: map['created_at'] != null
|
|
|
|
? (map['created_at'] is DateTime
|
|
|
|
? (map['created_at'] as DateTime)
|
|
|
|
: DateTime.parse(map['created_at'].toString()))
|
|
|
|
: null,
|
|
|
|
updatedAt: map['updated_at'] != null
|
|
|
|
? (map['updated_at'] is DateTime
|
|
|
|
? (map['updated_at'] as DateTime)
|
|
|
|
: DateTime.parse(map['updated_at'].toString()))
|
|
|
|
: null);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:51:27 +00:00
|
|
|
static Map<String, dynamic> toMap(_Leg model) {
|
2018-12-08 21:00:31 +00:00
|
|
|
if (model == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
'id': model.id,
|
|
|
|
'foot': FootSerializer.toMap(model.foot),
|
|
|
|
'name': model.name,
|
|
|
|
'created_at': model.createdAt?.toIso8601String(),
|
|
|
|
'updated_at': model.updatedAt?.toIso8601String()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class LegFields {
|
|
|
|
static const List<String> allFields = const <String>[
|
|
|
|
id,
|
|
|
|
foot,
|
|
|
|
name,
|
|
|
|
createdAt,
|
|
|
|
updatedAt
|
|
|
|
];
|
|
|
|
|
|
|
|
static const String id = 'id';
|
|
|
|
|
|
|
|
static const String foot = 'foot';
|
|
|
|
|
|
|
|
static const String name = 'name';
|
|
|
|
|
|
|
|
static const String createdAt = 'created_at';
|
|
|
|
|
|
|
|
static const String updatedAt = 'updated_at';
|
|
|
|
}
|