259 lines
6 KiB
Dart
259 lines
6 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of angel_orm_generator.test.models.leg;
|
|
|
|
// **************************************************************************
|
|
// 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');
|
|
}
|
|
}
|
|
|
|
// **************************************************************************
|
|
// OrmGenerator
|
|
// **************************************************************************
|
|
|
|
class LegQuery extends Query<Leg, LegQueryWhere> {
|
|
LegQuery({Set<String> trampoline}) {
|
|
trampoline ??= Set();
|
|
trampoline.add(tableName);
|
|
_where = LegQueryWhere(this);
|
|
leftJoin('feet', 'id', 'leg_id', additionalFields: const [
|
|
'id',
|
|
'leg_id',
|
|
'n_toes',
|
|
'created_at',
|
|
'updated_at'
|
|
]);
|
|
}
|
|
|
|
@override
|
|
final LegQueryValues values = LegQueryValues();
|
|
|
|
LegQueryWhere _where;
|
|
|
|
@override
|
|
get casts {
|
|
return {};
|
|
}
|
|
|
|
@override
|
|
get tableName {
|
|
return 'legs';
|
|
}
|
|
|
|
@override
|
|
get fields {
|
|
return const ['id', 'name', 'created_at', 'updated_at'];
|
|
}
|
|
|
|
@override
|
|
LegQueryWhere get where {
|
|
return _where;
|
|
}
|
|
|
|
@override
|
|
LegQueryWhere newWhereClause() {
|
|
return LegQueryWhere(this);
|
|
}
|
|
|
|
static Leg parseRow(List row) {
|
|
if (row.every((x) => x == null)) return null;
|
|
var model = 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);
|
|
}
|
|
}
|
|
|
|
class LegQueryWhere extends QueryWhere {
|
|
LegQueryWhere(LegQuery query)
|
|
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
|
|
name = StringSqlExpressionBuilder(query, 'name'),
|
|
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
|
|
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
|
|
|
|
final NumericSqlExpressionBuilder<int> id;
|
|
|
|
final StringSqlExpressionBuilder name;
|
|
|
|
final DateTimeSqlExpressionBuilder createdAt;
|
|
|
|
final DateTimeSqlExpressionBuilder updatedAt;
|
|
|
|
@override
|
|
get expressionBuilders {
|
|
return [id, name, createdAt, updatedAt];
|
|
}
|
|
}
|
|
|
|
class LegQueryValues extends MapQueryValues {
|
|
@override
|
|
get casts {
|
|
return {};
|
|
}
|
|
|
|
int get id {
|
|
return (values['id'] as int);
|
|
}
|
|
|
|
set id(int value) => values['id'] = value;
|
|
String get name {
|
|
return (values['name'] as String);
|
|
}
|
|
|
|
set name(String value) => values['name'] = value;
|
|
DateTime get createdAt {
|
|
return (values['created_at'] as DateTime);
|
|
}
|
|
|
|
set createdAt(DateTime value) => values['created_at'] = value;
|
|
DateTime get updatedAt {
|
|
return (values['updated_at'] as DateTime);
|
|
}
|
|
|
|
set updatedAt(DateTime value) => values['updated_at'] = value;
|
|
void copyFrom(Leg model) {
|
|
name = model.name;
|
|
createdAt = model.createdAt;
|
|
updatedAt = model.updatedAt;
|
|
}
|
|
}
|
|
|
|
// **************************************************************************
|
|
// JsonModelGenerator
|
|
// **************************************************************************
|
|
|
|
@generatedSerializable
|
|
class Leg extends _Leg {
|
|
Leg({this.id, this.foot, this.name, this.createdAt, this.updatedAt});
|
|
|
|
@override
|
|
final String id;
|
|
|
|
@override
|
|
final Foot foot;
|
|
|
|
@override
|
|
final String name;
|
|
|
|
@override
|
|
final DateTime createdAt;
|
|
|
|
@override
|
|
final DateTime updatedAt;
|
|
|
|
Leg copyWith(
|
|
{String id,
|
|
Foot foot,
|
|
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;
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return hashObjects([id, foot, name, createdAt, updatedAt]);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return LegSerializer.toMap(this);
|
|
}
|
|
}
|
|
|
|
// **************************************************************************
|
|
// 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);
|
|
}
|
|
|
|
static Map<String, dynamic> toMap(_Leg model) {
|
|
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 = <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';
|
|
}
|