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

250 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.fruit;
2018-12-09 17:44:16 +00:00
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class FruitMigration extends Migration {
@override
up(Schema schema) {
schema.create('fruits', (table) {
table.serial('id')..primaryKey();
table.integer('tree_id');
table.varChar('common_name');
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('fruits');
}
}
2018-12-01 19:03:43 +00:00
// **************************************************************************
// OrmGenerator
// **************************************************************************
class FruitQuery extends Query<Fruit, FruitQueryWhere> {
2018-12-31 12:22:05 +00:00
FruitQuery() {
_where = new FruitQueryWhere(this);
}
2018-12-03 16:50:43 +00:00
@override
final FruitQueryValues values = new FruitQueryValues();
2018-12-31 12:22:05 +00:00
FruitQueryWhere _where;
2018-12-01 19:03:43 +00:00
@override
get tableName {
return 'fruits';
}
@override
get fields {
2018-12-03 23:13:11 +00:00
return const ['id', 'tree_id', 'common_name', 'created_at', 'updated_at'];
2018-12-01 19:03:43 +00:00
}
2018-12-31 12:22:05 +00:00
@override
FruitQueryWhere get where {
return _where;
}
2018-12-03 16:50:43 +00:00
@override
FruitQueryWhere newWhereClause() {
2018-12-31 12:22:05 +00:00
return new FruitQueryWhere(this);
2018-12-03 16:50:43 +00:00
}
2018-12-03 23:13:11 +00:00
static Fruit 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 Fruit(
2018-12-03 13:41:14 +00:00
id: row[0].toString(),
treeId: (row[1] as int),
commonName: (row[2] as String),
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 FruitQueryWhere extends QueryWhere {
2018-12-31 12:22:05 +00:00
FruitQueryWhere(FruitQuery query)
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
treeId = new NumericSqlExpressionBuilder<int>(query, 'tree_id'),
commonName = new StringSqlExpressionBuilder(query, 'common_name'),
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
2018-12-01 19:03:43 +00:00
2018-12-31 12:22:05 +00:00
final NumericSqlExpressionBuilder<int> treeId;
2018-12-01 19:03:43 +00:00
2018-12-31 12:22:05 +00:00
final StringSqlExpressionBuilder commonName;
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, treeId, commonName, createdAt, updatedAt];
}
}
2018-12-03 16:50:43 +00:00
class FruitQueryValues 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 16:50:43 +00:00
int get treeId {
return (values['tree_id'] as int);
}
2018-12-31 12:22:05 +00:00
set treeId(int value) => values['tree_id'] = value;
2018-12-03 16:50:43 +00:00
String get commonName {
return (values['common_name'] as String);
}
2018-12-31 12:22:05 +00:00
set commonName(String value) => values['common_name'] = value;
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(Fruit model) {
values.addAll({
'tree_id': model.treeId,
'common_name': model.commonName,
'created_at': model.createdAt,
'updated_at': model.updatedAt
});
}
}
2018-08-24 13:42:09 +00:00
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Fruit extends _Fruit {
Fruit(
{this.id, this.treeId, this.commonName, this.createdAt, this.updatedAt});
@override
final String id;
@override
final int treeId;
@override
final String commonName;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Fruit copyWith(
{String id,
int treeId,
String commonName,
DateTime createdAt,
DateTime updatedAt}) {
return new Fruit(
id: id ?? this.id,
treeId: treeId ?? this.treeId,
commonName: commonName ?? this.commonName,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Fruit &&
other.id == id &&
other.treeId == treeId &&
other.commonName == commonName &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
2018-12-01 19:03:43 +00:00
@override
int get hashCode {
return hashObjects([id, treeId, commonName, createdAt, updatedAt]);
}
2018-08-24 13:42:09 +00:00
Map<String, dynamic> toJson() {
return FruitSerializer.toMap(this);
}
}
2018-12-08 21:00:31 +00:00
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class FruitSerializer {
static Fruit fromMap(Map map) {
return new Fruit(
id: map['id'] as String,
treeId: map['tree_id'] as int,
commonName: map['common_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(_Fruit model) {
2018-12-08 21:00:31 +00:00
if (model == null) {
return null;
}
return {
'id': model.id,
'tree_id': model.treeId,
'common_name': model.commonName,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class FruitFields {
static const List<String> allFields = const <String>[
id,
treeId,
commonName,
createdAt,
updatedAt
];
static const String id = 'id';
static const String treeId = 'tree_id';
static const String commonName = 'common_name';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}