// GENERATED CODE - DO NOT MODIFY BY HAND part of 'database.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** Preferences _$PreferencesFromJson(Map json) { return Preferences( json['receiveEmails'] as bool, ); } Map _$PreferencesToJson(Preferences instance) => { 'receiveEmails': instance.receiveEmails, }; // ************************************************************************** // MoorGenerator // ************************************************************************** // ignore_for_file: unnecessary_brace_in_string_interps class User extends DataClass implements Insertable { final int id; final String name; final DateTime birthDate; final Uint8List profilePicture; User( {@required this.id, @required this.name, @required this.birthDate, this.profilePicture}); factory User.fromData(Map data, GeneratedDatabase db, {String prefix}) { final effectivePrefix = prefix ?? ''; final intType = db.typeSystem.forDartType(); final stringType = db.typeSystem.forDartType(); final dateTimeType = db.typeSystem.forDartType(); final uint8ListType = db.typeSystem.forDartType(); return User( id: intType.mapFromDatabaseResponse(data['${effectivePrefix}id']), name: stringType.mapFromDatabaseResponse(data['${effectivePrefix}name']), birthDate: dateTimeType .mapFromDatabaseResponse(data['${effectivePrefix}birth_date']), profilePicture: uint8ListType .mapFromDatabaseResponse(data['${effectivePrefix}profile_picture']), ); } factory User.fromJson(Map json, {ValueSerializer serializer = const ValueSerializer.defaults()}) { return User( id: serializer.fromJson(json['id']), name: serializer.fromJson(json['name']), birthDate: serializer.fromJson(json['born_on']), profilePicture: serializer.fromJson(json['profilePicture']), ); } @override Map toJson( {ValueSerializer serializer = const ValueSerializer.defaults()}) { return { 'id': serializer.toJson(id), 'name': serializer.toJson(name), 'born_on': serializer.toJson(birthDate), 'profilePicture': serializer.toJson(profilePicture), }; } @override T createCompanion>(bool nullToAbsent) { return UsersCompanion( id: id == null && nullToAbsent ? const Value.absent() : Value(id), name: name == null && nullToAbsent ? const Value.absent() : Value(name), birthDate: birthDate == null && nullToAbsent ? const Value.absent() : Value(birthDate), profilePicture: profilePicture == null && nullToAbsent ? const Value.absent() : Value(profilePicture), ) as T; } User copyWith( {int id, String name, DateTime birthDate, Uint8List profilePicture}) => User( id: id ?? this.id, name: name ?? this.name, birthDate: birthDate ?? this.birthDate, profilePicture: profilePicture ?? this.profilePicture, ); @override String toString() { return (StringBuffer('User(') ..write('id: $id, ') ..write('name: $name, ') ..write('birthDate: $birthDate, ') ..write('profilePicture: $profilePicture') ..write(')')) .toString(); } @override int get hashCode => $mrjf($mrjc( id.hashCode, $mrjc( name.hashCode, $mrjc(birthDate.hashCode, profilePicture.hashCode)))); @override bool operator ==(other) => identical(this, other) || (other is User && other.id == id && other.name == name && other.birthDate == birthDate && other.profilePicture == profilePicture); } class UsersCompanion extends UpdateCompanion { final Value id; final Value name; final Value birthDate; final Value profilePicture; const UsersCompanion({ this.id = const Value.absent(), this.name = const Value.absent(), this.birthDate = const Value.absent(), this.profilePicture = const Value.absent(), }); } class $UsersTable extends Users with TableInfo<$UsersTable, User> { final GeneratedDatabase _db; final String _alias; $UsersTable(this._db, [this._alias]); final VerificationMeta _idMeta = const VerificationMeta('id'); GeneratedIntColumn _id; @override GeneratedIntColumn get id => _id ??= _constructId(); GeneratedIntColumn _constructId() { return GeneratedIntColumn('id', $tableName, false, hasAutoIncrement: true); } final VerificationMeta _nameMeta = const VerificationMeta('name'); GeneratedTextColumn _name; @override GeneratedTextColumn get name => _name ??= _constructName(); GeneratedTextColumn _constructName() { return GeneratedTextColumn( 'name', $tableName, false, ); } final VerificationMeta _birthDateMeta = const VerificationMeta('birthDate'); GeneratedDateTimeColumn _birthDate; @override GeneratedDateTimeColumn get birthDate => _birthDate ??= _constructBirthDate(); GeneratedDateTimeColumn _constructBirthDate() { return GeneratedDateTimeColumn( 'birth_date', $tableName, false, ); } final VerificationMeta _profilePictureMeta = const VerificationMeta('profilePicture'); GeneratedBlobColumn _profilePicture; @override GeneratedBlobColumn get profilePicture => _profilePicture ??= _constructProfilePicture(); GeneratedBlobColumn _constructProfilePicture() { return GeneratedBlobColumn( 'profile_picture', $tableName, true, ); } @override List get $columns => [id, name, birthDate, profilePicture]; @override $UsersTable get asDslTable => this; @override String get $tableName => _alias ?? 'users'; @override final String actualTableName = 'users'; @override VerificationContext validateIntegrity(UsersCompanion d, {bool isInserting = false}) { final context = VerificationContext(); if (d.id.present) { context.handle(_idMeta, id.isAcceptableValue(d.id.value, _idMeta)); } else if (id.isRequired && isInserting) { context.missing(_idMeta); } if (d.name.present) { context.handle( _nameMeta, name.isAcceptableValue(d.name.value, _nameMeta)); } else if (name.isRequired && isInserting) { context.missing(_nameMeta); } if (d.birthDate.present) { context.handle(_birthDateMeta, birthDate.isAcceptableValue(d.birthDate.value, _birthDateMeta)); } else if (birthDate.isRequired && isInserting) { context.missing(_birthDateMeta); } if (d.profilePicture.present) { context.handle( _profilePictureMeta, profilePicture.isAcceptableValue( d.profilePicture.value, _profilePictureMeta)); } else if (profilePicture.isRequired && isInserting) { context.missing(_profilePictureMeta); } return context; } @override Set get $primaryKey => {id}; @override User map(Map data, {String tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return User.fromData(data, _db, prefix: effectivePrefix); } @override Map entityToSql(UsersCompanion d) { final map = {}; if (d.id.present) { map['id'] = Variable(d.id.value); } if (d.name.present) { map['name'] = Variable(d.name.value); } if (d.birthDate.present) { map['birth_date'] = Variable(d.birthDate.value); } if (d.profilePicture.present) { map['profile_picture'] = Variable(d.profilePicture.value); } return map; } @override $UsersTable createAlias(String alias) { return $UsersTable(_db, alias); } } class Friendship extends DataClass implements Insertable { final int firstUser; final int secondUser; final bool reallyGoodFriends; Friendship( {@required this.firstUser, @required this.secondUser, @required this.reallyGoodFriends}); factory Friendship.fromData(Map data, GeneratedDatabase db, {String prefix}) { final effectivePrefix = prefix ?? ''; final intType = db.typeSystem.forDartType(); final boolType = db.typeSystem.forDartType(); return Friendship( firstUser: intType.mapFromDatabaseResponse(data['${effectivePrefix}first_user']), secondUser: intType .mapFromDatabaseResponse(data['${effectivePrefix}second_user']), reallyGoodFriends: boolType.mapFromDatabaseResponse( data['${effectivePrefix}really_good_friends']), ); } factory Friendship.fromJson(Map json, {ValueSerializer serializer = const ValueSerializer.defaults()}) { return Friendship( firstUser: serializer.fromJson(json['firstUser']), secondUser: serializer.fromJson(json['secondUser']), reallyGoodFriends: serializer.fromJson(json['reallyGoodFriends']), ); } @override Map toJson( {ValueSerializer serializer = const ValueSerializer.defaults()}) { return { 'firstUser': serializer.toJson(firstUser), 'secondUser': serializer.toJson(secondUser), 'reallyGoodFriends': serializer.toJson(reallyGoodFriends), }; } @override T createCompanion>(bool nullToAbsent) { return FriendshipsCompanion( firstUser: firstUser == null && nullToAbsent ? const Value.absent() : Value(firstUser), secondUser: secondUser == null && nullToAbsent ? const Value.absent() : Value(secondUser), reallyGoodFriends: reallyGoodFriends == null && nullToAbsent ? const Value.absent() : Value(reallyGoodFriends), ) as T; } Friendship copyWith( {int firstUser, int secondUser, bool reallyGoodFriends}) => Friendship( firstUser: firstUser ?? this.firstUser, secondUser: secondUser ?? this.secondUser, reallyGoodFriends: reallyGoodFriends ?? this.reallyGoodFriends, ); @override String toString() { return (StringBuffer('Friendship(') ..write('firstUser: $firstUser, ') ..write('secondUser: $secondUser, ') ..write('reallyGoodFriends: $reallyGoodFriends') ..write(')')) .toString(); } @override int get hashCode => $mrjf($mrjc(firstUser.hashCode, $mrjc(secondUser.hashCode, reallyGoodFriends.hashCode))); @override bool operator ==(other) => identical(this, other) || (other is Friendship && other.firstUser == firstUser && other.secondUser == secondUser && other.reallyGoodFriends == reallyGoodFriends); } class FriendshipsCompanion extends UpdateCompanion { final Value firstUser; final Value secondUser; final Value reallyGoodFriends; const FriendshipsCompanion({ this.firstUser = const Value.absent(), this.secondUser = const Value.absent(), this.reallyGoodFriends = const Value.absent(), }); } class $FriendshipsTable extends Friendships with TableInfo<$FriendshipsTable, Friendship> { final GeneratedDatabase _db; final String _alias; $FriendshipsTable(this._db, [this._alias]); final VerificationMeta _firstUserMeta = const VerificationMeta('firstUser'); GeneratedIntColumn _firstUser; @override GeneratedIntColumn get firstUser => _firstUser ??= _constructFirstUser(); GeneratedIntColumn _constructFirstUser() { return GeneratedIntColumn( 'first_user', $tableName, false, ); } final VerificationMeta _secondUserMeta = const VerificationMeta('secondUser'); GeneratedIntColumn _secondUser; @override GeneratedIntColumn get secondUser => _secondUser ??= _constructSecondUser(); GeneratedIntColumn _constructSecondUser() { return GeneratedIntColumn( 'second_user', $tableName, false, ); } final VerificationMeta _reallyGoodFriendsMeta = const VerificationMeta('reallyGoodFriends'); GeneratedBoolColumn _reallyGoodFriends; @override GeneratedBoolColumn get reallyGoodFriends => _reallyGoodFriends ??= _constructReallyGoodFriends(); GeneratedBoolColumn _constructReallyGoodFriends() { return GeneratedBoolColumn('really_good_friends', $tableName, false, defaultValue: const Constant(false)); } @override List get $columns => [firstUser, secondUser, reallyGoodFriends]; @override $FriendshipsTable get asDslTable => this; @override String get $tableName => _alias ?? 'friendships'; @override final String actualTableName = 'friendships'; @override VerificationContext validateIntegrity(FriendshipsCompanion d, {bool isInserting = false}) { final context = VerificationContext(); if (d.firstUser.present) { context.handle(_firstUserMeta, firstUser.isAcceptableValue(d.firstUser.value, _firstUserMeta)); } else if (firstUser.isRequired && isInserting) { context.missing(_firstUserMeta); } if (d.secondUser.present) { context.handle(_secondUserMeta, secondUser.isAcceptableValue(d.secondUser.value, _secondUserMeta)); } else if (secondUser.isRequired && isInserting) { context.missing(_secondUserMeta); } if (d.reallyGoodFriends.present) { context.handle( _reallyGoodFriendsMeta, reallyGoodFriends.isAcceptableValue( d.reallyGoodFriends.value, _reallyGoodFriendsMeta)); } else if (reallyGoodFriends.isRequired && isInserting) { context.missing(_reallyGoodFriendsMeta); } return context; } @override Set get $primaryKey => {firstUser, secondUser}; @override Friendship map(Map data, {String tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return Friendship.fromData(data, _db, prefix: effectivePrefix); } @override Map entityToSql(FriendshipsCompanion d) { final map = {}; if (d.firstUser.present) { map['first_user'] = Variable(d.firstUser.value); } if (d.secondUser.present) { map['second_user'] = Variable(d.secondUser.value); } if (d.reallyGoodFriends.present) { map['really_good_friends'] = Variable(d.reallyGoodFriends.value); } return map; } @override $FriendshipsTable createAlias(String alias) { return $FriendshipsTable(_db, alias); } } class AmountOfGoodFriendsResult { final int count; AmountOfGoodFriendsResult({ this.count, }); } class UserCountResult { final int cOUNTid; UserCountResult({ this.cOUNTid, }); } abstract class _$Database extends GeneratedDatabase { _$Database(QueryExecutor e) : super(const SqlTypeSystem.withDefaults(), e); $UsersTable _users; $UsersTable get users => _users ??= $UsersTable(this); $FriendshipsTable _friendships; $FriendshipsTable get friendships => _friendships ??= $FriendshipsTable(this); User _rowToUser(QueryRow row) { return User( id: row.readInt('id'), name: row.readString('name'), birthDate: row.readDateTime('birth_date'), profilePicture: row.readBlob('profile_picture'), ); } Future> mostPopularUsers( int amount, {@Deprecated('No longer needed with Moor 1.6 - see the changelog for details') QueryEngine operateOn}) { return (operateOn ?? this).customSelect( 'SELECT * FROM users u ORDER BY (SELECT COUNT(*) FROM friendships WHERE first_user = u.id OR second_user = u.id) DESC LIMIT :amount', variables: [ Variable.withInt(amount), ]).then((rows) => rows.map(_rowToUser).toList()); } Stream> watchMostPopularUsers(int amount) { return customSelectStream( 'SELECT * FROM users u ORDER BY (SELECT COUNT(*) FROM friendships WHERE first_user = u.id OR second_user = u.id) DESC LIMIT :amount', variables: [ Variable.withInt(amount), ], readsFrom: { users, friendships }).map((rows) => rows.map(_rowToUser).toList()); } AmountOfGoodFriendsResult _rowToAmountOfGoodFriendsResult(QueryRow row) { return AmountOfGoodFriendsResult( count: row.readInt('COUNT(*)'), ); } Future> amountOfGoodFriends( int user, {@Deprecated('No longer needed with Moor 1.6 - see the changelog for details') QueryEngine operateOn}) { return (operateOn ?? this).customSelect( 'SELECT COUNT(*) FROM friendships f WHERE f.really_good_friends AND (f.first_user = :user OR f.second_user = :user)', variables: [ Variable.withInt(user), ]).then((rows) => rows.map(_rowToAmountOfGoodFriendsResult).toList()); } Stream> watchAmountOfGoodFriends(int user) { return customSelectStream( 'SELECT COUNT(*) FROM friendships f WHERE f.really_good_friends AND (f.first_user = :user OR f.second_user = :user)', variables: [ Variable.withInt(user), ], readsFrom: { friendships }).map((rows) => rows.map(_rowToAmountOfGoodFriendsResult).toList()); } UserCountResult _rowToUserCountResult(QueryRow row) { return UserCountResult( cOUNTid: row.readInt('COUNT(id)'), ); } Future> userCount( {@Deprecated('No longer needed with Moor 1.6 - see the changelog for details') QueryEngine operateOn}) { return (operateOn ?? this).customSelect('SELECT COUNT(id) FROM users', variables: []).then((rows) => rows.map(_rowToUserCountResult).toList()); } Stream> watchUserCount() { return customSelectStream('SELECT COUNT(id) FROM users', variables: [], readsFrom: {users}) .map((rows) => rows.map(_rowToUserCountResult).toList()); } @override List get allTables => [users, friendships]; }