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

329 lines
8 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.models.car;
2018-12-09 17:44:16 +00:00
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class CarMigration extends Migration {
@override
up(Schema schema) {
schema.create('cars', (table) {
table.serial('id')..primaryKey();
table.varChar('make');
table.varChar('description');
table.boolean('family_friendly');
table.timeStamp('recalled_at');
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('cars');
}
}
2018-12-01 19:03:43 +00:00
// **************************************************************************
// OrmGenerator
// **************************************************************************
class CarQuery extends Query<Car, CarQueryWhere> {
2018-12-31 12:22:05 +00:00
CarQuery() {
_where = new CarQueryWhere(this);
}
2018-12-03 16:50:43 +00:00
@override
final CarQueryValues values = new CarQueryValues();
2018-12-31 12:22:05 +00:00
CarQueryWhere _where;
2018-12-01 19:03:43 +00:00
@override
get tableName {
return 'cars';
}
@override
get fields {
2018-12-03 23:13:11 +00:00
return const [
'id',
'make',
'description',
'family_friendly',
'recalled_at',
'created_at',
'updated_at'
];
2018-12-01 19:03:43 +00:00
}
2018-12-31 12:22:05 +00:00
@override
CarQueryWhere get where {
return _where;
}
2018-12-03 16:50:43 +00:00
@override
CarQueryWhere newWhereClause() {
2018-12-31 12:22:05 +00:00
return new CarQueryWhere(this);
2018-12-03 16:50:43 +00:00
}
2018-12-03 23:13:11 +00:00
static Car 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 Car(
2018-12-03 13:41:14 +00:00
id: row[0].toString(),
make: (row[1] as String),
description: (row[2] as String),
familyFriendly: (row[3] as bool),
recalledAt: (row[4] as DateTime),
createdAt: (row[5] as DateTime),
updatedAt: (row[6] 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 CarQueryWhere extends QueryWhere {
2018-12-31 12:22:05 +00:00
CarQueryWhere(CarQuery query)
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
make = new StringSqlExpressionBuilder(query, 'make'),
description = new StringSqlExpressionBuilder(query, 'description'),
familyFriendly =
new BooleanSqlExpressionBuilder(query, 'family_friendly'),
recalledAt = new DateTimeSqlExpressionBuilder(query, 'recalled_at'),
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 StringSqlExpressionBuilder make;
2018-12-01 19:03:43 +00:00
2018-12-31 12:22:05 +00:00
final StringSqlExpressionBuilder description;
2018-12-01 19:03:43 +00:00
2018-12-31 12:22:05 +00:00
final BooleanSqlExpressionBuilder familyFriendly;
2018-12-01 19:03:43 +00:00
2018-12-31 12:22:05 +00:00
final DateTimeSqlExpressionBuilder recalledAt;
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,
make,
description,
familyFriendly,
recalledAt,
createdAt,
updatedAt
];
}
}
2018-12-03 16:50:43 +00:00
class CarQueryValues 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
String get make {
return (values['make'] as String);
}
2018-12-31 12:22:05 +00:00
set make(String value) => values['make'] = value;
2018-12-03 16:50:43 +00:00
String get description {
return (values['description'] as String);
}
2018-12-31 12:22:05 +00:00
set description(String value) => values['description'] = value;
2018-12-03 16:50:43 +00:00
bool get familyFriendly {
return (values['family_friendly'] as bool);
}
2018-12-31 12:22:05 +00:00
set familyFriendly(bool value) => values['family_friendly'] = value;
2018-12-03 16:50:43 +00:00
DateTime get recalledAt {
return (values['recalled_at'] as DateTime);
}
2018-12-31 12:22:05 +00:00
set recalledAt(DateTime value) => values['recalled_at'] = 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(Car model) {
values.addAll({
'make': model.make,
'description': model.description,
'family_friendly': model.familyFriendly,
'recalled_at': model.recalledAt,
'created_at': model.createdAt,
'updated_at': model.updatedAt
});
}
}
2018-08-24 13:42:09 +00:00
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Car extends _Car {
Car(
{this.id,
this.make,
this.description,
this.familyFriendly,
this.recalledAt,
this.createdAt,
this.updatedAt});
@override
final String id;
@override
final String make;
@override
final String description;
@override
final bool familyFriendly;
@override
final DateTime recalledAt;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Car copyWith(
{String id,
String make,
String description,
bool familyFriendly,
DateTime recalledAt,
DateTime createdAt,
DateTime updatedAt}) {
return new Car(
id: id ?? this.id,
make: make ?? this.make,
description: description ?? this.description,
familyFriendly: familyFriendly ?? this.familyFriendly,
recalledAt: recalledAt ?? this.recalledAt,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Car &&
other.id == id &&
other.make == make &&
other.description == description &&
other.familyFriendly == familyFriendly &&
other.recalledAt == recalledAt &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
2018-12-01 19:03:43 +00:00
@override
int get hashCode {
return hashObjects([
id,
make,
description,
familyFriendly,
recalledAt,
createdAt,
updatedAt
]);
}
2018-08-24 13:42:09 +00:00
Map<String, dynamic> toJson() {
return CarSerializer.toMap(this);
}
}
2018-12-08 21:00:31 +00:00
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class CarSerializer {
static Car fromMap(Map map) {
return new Car(
id: map['id'] as String,
make: map['make'] as String,
description: map['description'] as String,
familyFriendly: map['family_friendly'] as bool,
recalledAt: map['recalled_at'] != null
? (map['recalled_at'] is DateTime
? (map['recalled_at'] as DateTime)
: DateTime.parse(map['recalled_at'].toString()))
: null,
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(_Car model) {
2018-12-08 21:00:31 +00:00
if (model == null) {
return null;
}
return {
'id': model.id,
'make': model.make,
'description': model.description,
'family_friendly': model.familyFriendly,
'recalled_at': model.recalledAt?.toIso8601String(),
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class CarFields {
static const List<String> allFields = const <String>[
id,
make,
description,
familyFriendly,
recalledAt,
createdAt,
updatedAt
];
static const String id = 'id';
static const String make = 'make';
static const String description = 'description';
static const String familyFriendly = 'family_friendly';
static const String recalledAt = 'recalled_at';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}