platform/angel_orm_generator/test/models/foot.g.dart

259 lines
6.2 KiB
Dart
Raw Normal View History

2018-08-24 13:42:09 +00:00
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm_generator.test.models.foot;
2018-12-09 17:44:16 +00:00
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class FootMigration extends Migration {
@override
up(Schema schema) {
schema.create('feet', (table) {
table.serial('id')..primaryKey();
table.integer('leg_id');
2019-02-07 03:27:47 +00:00
table.declare('n_toes', ColumnType('decimal'));
2018-12-09 17:44:16 +00:00
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('feet');
}
}
2018-12-01 19:03:43 +00:00
// **************************************************************************
// OrmGenerator
// **************************************************************************
class FootQuery extends Query<Foot, FootQueryWhere> {
2019-01-27 04:14:20 +00:00
FootQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
2019-02-07 03:27:47 +00:00
_where = FootQueryWhere(this);
2018-12-31 12:22:05 +00:00
}
2018-12-03 16:50:43 +00:00
@override
2019-02-07 03:27:47 +00:00
final FootQueryValues values = FootQueryValues();
2018-12-03 16:50:43 +00:00
2018-12-31 12:22:05 +00:00
FootQueryWhere _where;
2018-12-01 19:03:43 +00:00
2019-01-27 04:14:20 +00:00
@override
get casts {
return {'n_toes': 'text'};
}
2018-12-01 19:03:43 +00:00
@override
get tableName {
2018-12-08 02:57:09 +00:00
return 'feet';
2018-12-01 19:03:43 +00:00
}
@override
get fields {
2018-12-03 23:13:11 +00:00
return const ['id', 'leg_id', 'n_toes', 'created_at', 'updated_at'];
2018-12-01 19:03:43 +00:00
}
2018-12-31 12:22:05 +00:00
@override
FootQueryWhere get where {
return _where;
}
2018-12-03 16:50:43 +00:00
@override
FootQueryWhere newWhereClause() {
2019-02-07 03:27:47 +00:00
return FootQueryWhere(this);
2018-12-03 16:50:43 +00:00
}
2018-12-03 23:13:11 +00:00
static Foot parseRow(List row) {
2018-12-08 02:57:09 +00:00
if (row.every((x) => x == null)) return null;
2019-02-07 03:27:47 +00:00
var model = Foot(
2018-12-03 13:41:14 +00:00
id: row[0].toString(),
legId: (row[1] as int),
2019-01-27 04:14:20 +00:00
nToes: double.parse(row[2].toString()),
2018-12-03 13:41:14 +00:00
createdAt: (row[3] as DateTime),
updatedAt: (row[4] as DateTime));
2018-12-03 23:13:11 +00:00
return model;
}
@override
deserialize(List row) {
return parseRow(row);
2018-12-01 19:03:43 +00:00
}
}
class FootQueryWhere extends QueryWhere {
2018-12-31 12:22:05 +00:00
FootQueryWhere(FootQuery query)
2019-02-07 03:27:47 +00:00
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
legId = NumericSqlExpressionBuilder<int>(query, 'leg_id'),
nToes = NumericSqlExpressionBuilder<double>(query, 'n_toes'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
2018-12-31 12:22:05 +00:00
final NumericSqlExpressionBuilder<int> id;
2018-12-01 19:03:43 +00:00
2018-12-31 12:22:05 +00:00
final NumericSqlExpressionBuilder<int> legId;
2018-12-01 19:03:43 +00:00
2019-01-27 04:14:20 +00:00
final NumericSqlExpressionBuilder<double> nToes;
2018-12-01 19:03:43 +00:00
2018-12-31 12:22:05 +00:00
final DateTimeSqlExpressionBuilder createdAt;
2018-12-01 19:03:43 +00:00
2018-12-31 12:22:05 +00:00
final DateTimeSqlExpressionBuilder updatedAt;
2018-12-01 19:03:43 +00:00
@override
get expressionBuilders {
return [id, legId, nToes, createdAt, updatedAt];
}
}
2018-12-03 16:50:43 +00:00
class FootQueryValues extends MapQueryValues {
2019-01-24 17:20:34 +00:00
@override
get casts {
2019-01-27 04:14:20 +00:00
return {'n_toes': 'decimal'};
2019-01-24 17:20:34 +00:00
}
2018-12-03 16:50:43 +00:00
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 16:50:43 +00:00
int get legId {
return (values['leg_id'] as int);
}
2018-12-31 12:22:05 +00:00
set legId(int value) => values['leg_id'] = value;
2019-01-27 04:14:20 +00:00
double get nToes {
return double.parse((values['n_toes'] as String));
2018-12-03 16:50:43 +00:00
}
2019-01-27 04:14:20 +00:00
set nToes(double value) => values['n_toes'] = value.toString();
2018-12-03 16:50:43 +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 16:50:43 +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 16:50:43 +00:00
void copyFrom(Foot model) {
2019-01-24 17:20:34 +00:00
legId = model.legId;
nToes = model.nToes;
createdAt = model.createdAt;
updatedAt = model.updatedAt;
2018-12-03 16:50:43 +00:00
}
}
2018-08-24 13:42:09 +00:00
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Foot extends _Foot {
Foot({this.id, this.legId, this.nToes, this.createdAt, this.updatedAt});
@override
final String id;
@override
final int legId;
@override
2019-01-27 04:14:20 +00:00
final double nToes;
2018-08-24 13:42:09 +00:00
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Foot copyWith(
{String id,
int legId,
2019-01-27 04:14:20 +00:00
double nToes,
2018-08-24 13:42:09 +00:00
DateTime createdAt,
DateTime updatedAt}) {
return new Foot(
id: id ?? this.id,
legId: legId ?? this.legId,
nToes: nToes ?? this.nToes,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Foot &&
other.id == id &&
other.legId == legId &&
other.nToes == nToes &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
2018-12-01 19:03:43 +00:00
@override
int get hashCode {
return hashObjects([id, legId, nToes, createdAt, updatedAt]);
}
2018-08-24 13:42:09 +00:00
Map<String, dynamic> toJson() {
return FootSerializer.toMap(this);
}
}
2018-12-08 21:00:31 +00:00
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class FootSerializer {
static Foot fromMap(Map map) {
return new Foot(
id: map['id'] as String,
legId: map['leg_id'] as int,
2019-01-27 04:14:20 +00:00
nToes: map['n_toes'] as double,
2018-12-08 21:00:31 +00:00
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(_Foot model) {
2018-12-08 21:00:31 +00:00
if (model == null) {
return null;
}
return {
'id': model.id,
'leg_id': model.legId,
'n_toes': model.nToes,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class FootFields {
2019-02-07 03:27:47 +00:00
static const List<String> allFields = <String>[
2018-12-08 21:00:31 +00:00
id,
legId,
nToes,
createdAt,
updatedAt
];
static const String id = 'id';
static const String legId = 'leg_id';
static const String nToes = 'n_toes';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}