platform/angel_orm_generator/test/models/user.g.dart
2018-12-08 16:00:31 -05:00

250 lines
6 KiB
Dart

// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm_generator.test.models.user;
// **************************************************************************
// OrmGenerator
// **************************************************************************
class UserQuery extends Query<User, UserQueryWhere> {
@override
final UserQueryValues values = new UserQueryValues();
@override
final UserQueryWhere where = new UserQueryWhere();
@override
get tableName {
return 'users';
}
@override
get fields {
return const [
'id',
'username',
'password',
'email',
'created_at',
'updated_at'
];
}
@override
UserQueryWhere newWhereClause() {
return new UserQueryWhere();
}
static User parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = new User(
id: row[0].toString(),
username: (row[1] as String),
password: (row[2] as String),
email: (row[3] as String),
createdAt: (row[4] as DateTime),
updatedAt: (row[5] as DateTime));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class UserQueryWhere extends QueryWhere {
final NumericSqlExpressionBuilder<int> id =
new NumericSqlExpressionBuilder<int>('id');
final StringSqlExpressionBuilder username =
new StringSqlExpressionBuilder('username');
final StringSqlExpressionBuilder password =
new StringSqlExpressionBuilder('password');
final StringSqlExpressionBuilder email =
new StringSqlExpressionBuilder('email');
final DateTimeSqlExpressionBuilder createdAt =
new DateTimeSqlExpressionBuilder('created_at');
final DateTimeSqlExpressionBuilder updatedAt =
new DateTimeSqlExpressionBuilder('updated_at');
@override
get expressionBuilders {
return [id, username, password, email, createdAt, updatedAt];
}
}
class UserQueryValues extends MapQueryValues {
int get id {
return (values['id'] as int);
}
void set id(int value) => values['id'] = value;
String get username {
return (values['username'] as String);
}
void set username(String value) => values['username'] = value;
String get password {
return (values['password'] as String);
}
void set password(String value) => values['password'] = value;
String get email {
return (values['email'] as String);
}
void set email(String value) => values['email'] = 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(User model) {
values.addAll({
'username': model.username,
'password': model.password,
'email': model.email,
'created_at': model.createdAt,
'updated_at': model.updatedAt
});
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class User extends _User {
User(
{this.id,
this.username,
this.password,
this.email,
this.createdAt,
this.updatedAt});
@override
final String id;
@override
final String username;
@override
final String password;
@override
final String email;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
User copyWith(
{String id,
String username,
String password,
String email,
DateTime createdAt,
DateTime updatedAt}) {
return new User(
id: id ?? this.id,
username: username ?? this.username,
password: password ?? this.password,
email: email ?? this.email,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _User &&
other.id == id &&
other.username == username &&
other.password == password &&
other.email == email &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, username, password, email, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return UserSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class UserSerializer {
static User fromMap(Map map) {
return new User(
id: map['id'] as String,
username: map['username'] as String,
password: map['password'] as String,
email: map['email'] 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);
}
static Map<String, dynamic> toMap(User model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'username': model.username,
'password': model.password,
'email': model.email,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class UserFields {
static const List<String> allFields = const <String>[
id,
username,
password,
email,
createdAt,
updatedAt
];
static const String id = 'id';
static const String username = 'username';
static const String password = 'password';
static const String email = 'email';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}