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

170 lines
4.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.customer;
2018-12-01 19:03:43 +00:00
// **************************************************************************
// OrmGenerator
// **************************************************************************
class CustomerQuery extends Query<Customer, CustomerQueryWhere> {
2018-12-03 16:50:43 +00:00
@override
final CustomerQueryValues values = new CustomerQueryValues();
2018-12-01 19:03:43 +00:00
@override
final CustomerQueryWhere where = new CustomerQueryWhere();
@override
get tableName {
return 'customers';
}
@override
get fields {
2018-12-03 23:13:11 +00:00
return const ['id', 'created_at', 'updated_at'];
2018-12-01 19:03:43 +00:00
}
2018-12-03 16:50:43 +00:00
@override
CustomerQueryWhere newWhereClause() {
return new CustomerQueryWhere();
}
2018-12-03 23:13:11 +00:00
static Customer 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 Customer(
2018-12-03 13:41:14 +00:00
id: row[0].toString(),
createdAt: (row[1] as DateTime),
updatedAt: (row[2] 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 CustomerQueryWhere extends QueryWhere {
2018-12-03 13:41:14 +00:00
final NumericSqlExpressionBuilder<int> id =
new NumericSqlExpressionBuilder<int>('id');
2018-12-01 19:03:43 +00:00
final DateTimeSqlExpressionBuilder createdAt =
new DateTimeSqlExpressionBuilder('created_at');
final DateTimeSqlExpressionBuilder updatedAt =
new DateTimeSqlExpressionBuilder('updated_at');
@override
get expressionBuilders {
return [id, createdAt, updatedAt];
}
}
2018-12-03 16:50:43 +00:00
class CustomerQueryValues extends MapQueryValues {
int get id {
return (values['id'] as int);
}
void set id(int value) => values['id'] = value;
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
void set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
void set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(Customer model) {
values
.addAll({'created_at': model.createdAt, 'updated_at': model.updatedAt});
}
}
2018-08-24 13:42:09 +00:00
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Customer extends _Customer {
Customer({this.id, this.createdAt, this.updatedAt});
@override
final String id;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Customer copyWith({String id, DateTime createdAt, DateTime updatedAt}) {
return new Customer(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Customer &&
other.id == id &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
2018-12-01 19:03:43 +00:00
@override
int get hashCode {
return hashObjects([id, createdAt, updatedAt]);
}
2018-08-24 13:42:09 +00:00
Map<String, dynamic> toJson() {
return CustomerSerializer.toMap(this);
}
}
2018-12-08 21:00:31 +00:00
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class CustomerSerializer {
static Customer fromMap(Map map) {
return new Customer(
id: map['id'] 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(_Customer model) {
2018-12-08 21:00:31 +00:00
if (model == null) {
return null;
}
return {
'id': model.id,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class CustomerFields {
static const List<String> allFields = const <String>[
id,
createdAt,
updatedAt
];
static const String id = 'id';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}