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

212 lines
4.6 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.book;
2018-12-09 17:44:16 +00:00
// **************************************************************************
2018-12-03 23:13:11 +00:00
// OrmGenerator
// **************************************************************************
class BookQuery extends Query<Book, BookQueryWhere> {
2019-01-27 04:14:20 +00:00
BookQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
2019-02-07 03:27:47 +00:00
_where = BookQueryWhere(this);
2018-12-08 02:03:03 +00:00
}
2018-12-03 23:13:11 +00:00
@override
2019-02-07 03:27:47 +00:00
final BookQueryValues values = BookQueryValues();
2018-12-03 23:13:11 +00:00
2018-12-31 12:22:05 +00:00
BookQueryWhere _where;
2018-12-03 23:13:11 +00:00
2019-01-27 04:14:20 +00:00
@override
get casts {
return {};
}
2018-12-03 23:13:11 +00:00
@override
get tableName {
return 'books';
}
@override
get fields {
2019-02-07 03:27:47 +00:00
return const ['id'];
2018-12-03 23:13:11 +00:00
}
2018-12-31 12:22:05 +00:00
@override
BookQueryWhere get where {
return _where;
}
2018-12-03 23:13:11 +00:00
@override
BookQueryWhere newWhereClause() {
2019-02-07 03:27:47 +00:00
return BookQueryWhere(this);
2018-12-03 23:13:11 +00:00
}
static Book 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 = Book(id: row[0].toString());
2018-12-03 23:13:11 +00:00
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class BookQueryWhere extends QueryWhere {
2018-12-31 12:22:05 +00:00
BookQueryWhere(BookQuery query)
2019-02-07 03:27:47 +00:00
: id = NumericSqlExpressionBuilder<int>(query, 'id');
2018-12-31 12:22:05 +00:00
final NumericSqlExpressionBuilder<int> id;
2018-12-03 23:13:11 +00:00
@override
get expressionBuilders {
2019-02-07 03:27:47 +00:00
return [id];
2018-12-03 23:13:11 +00:00
}
}
class BookQueryValues extends MapQueryValues {
2019-01-24 17:20:34 +00:00
@override
get casts {
return {};
}
2018-12-03 23:13:11 +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;
2019-02-07 03:27:47 +00:00
void copyFrom(Book model) {}
2018-12-03 23:13:11 +00:00
}
2018-08-24 13:42:09 +00:00
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Book extends _Book {
Book(
{this.id,
this.author,
this.partnerAuthor,
this.name,
this.createdAt,
this.updatedAt});
@override
final String id;
@override
2019-02-07 03:27:47 +00:00
final dynamic author;
2018-08-24 13:42:09 +00:00
@override
2019-02-07 03:27:47 +00:00
final dynamic partnerAuthor;
2018-08-24 13:42:09 +00:00
@override
final String name;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Book copyWith(
{String id,
2019-02-07 03:27:47 +00:00
dynamic author,
dynamic partnerAuthor,
2018-08-24 13:42:09 +00:00
String name,
DateTime createdAt,
DateTime updatedAt}) {
return new Book(
id: id ?? this.id,
author: author ?? this.author,
partnerAuthor: partnerAuthor ?? this.partnerAuthor,
name: name ?? this.name,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Book &&
other.id == id &&
other.author == author &&
other.partnerAuthor == partnerAuthor &&
other.name == name &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
2018-12-01 19:03:43 +00:00
@override
int get hashCode {
2018-12-03 23:13:11 +00:00
return hashObjects([id, author, partnerAuthor, name, createdAt, updatedAt]);
2018-12-01 19:03:43 +00:00
}
2018-08-24 13:42:09 +00:00
Map<String, dynamic> toJson() {
return BookSerializer.toMap(this);
}
}
2018-12-08 21:00:31 +00:00
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class BookSerializer {
static Book fromMap(Map map) {
return new Book(
id: map['id'] as String,
2019-02-07 03:27:47 +00:00
author: map['author'] as dynamic,
partnerAuthor: map['partner_author'] as dynamic,
2018-12-08 21:00:31 +00:00
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);
}
2018-12-08 22:51:27 +00:00
static Map<String, dynamic> toMap(_Book model) {
2018-12-08 21:00:31 +00:00
if (model == null) {
return null;
}
return {
'id': model.id,
2019-02-07 03:27:47 +00:00
'author': model.author,
'partner_author': model.partnerAuthor,
2018-12-08 21:00:31 +00:00
'name': model.name,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class BookFields {
2019-02-07 03:27:47 +00:00
static const List<String> allFields = <String>[
2018-12-08 21:00:31 +00:00
id,
author,
partnerAuthor,
name,
createdAt,
updatedAt
];
static const String id = 'id';
static const String author = 'author';
static const String partnerAuthor = 'partner_author';
static const String name = 'name';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}