// GENERATED CODE - DO NOT MODIFY BY HAND part of 'chat_database.dart'; // ignore_for_file: type=lint class $MessagesTable extends Messages with TableInfo<$MessagesTable, Message> { @override final GeneratedDatabase attachedDatabase; final String? _alias; $MessagesTable(this.attachedDatabase, [this._alias]); static const VerificationMeta _idMeta = const VerificationMeta('id'); @override late final GeneratedColumn id = GeneratedColumn( 'id', aliasedName, false, hasAutoIncrement: true, type: DriftSqlType.int, requiredDuringInsert: false, defaultConstraints: GeneratedColumn.constraintIsAlways( 'PRIMARY KEY AUTOINCREMENT', ), ); static const VerificationMeta _accountScopeMeta = const VerificationMeta( 'accountScope', ); @override late final GeneratedColumn accountScope = GeneratedColumn( 'account_scope', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, ); static const VerificationMeta _peerPubkeyMeta = const VerificationMeta( 'peerPubkey', ); @override late final GeneratedColumn peerPubkey = GeneratedColumn( 'peer_pubkey', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, ); static const VerificationMeta _fromPubkeyMeta = const VerificationMeta( 'fromPubkey', ); @override late final GeneratedColumn fromPubkey = GeneratedColumn( 'from_pubkey', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, ); static const VerificationMeta _bodyMeta = const VerificationMeta('body'); @override late final GeneratedColumn body = GeneratedColumn( 'body', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, ); static const VerificationMeta _sentAtMeta = const VerificationMeta('sentAt'); @override late final GeneratedColumn sentAt = GeneratedColumn( 'sent_at', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: true, ); @override List get $columns => [ id, accountScope, peerPubkey, fromPubkey, body, sentAt, ]; @override String get aliasedName => _alias ?? actualTableName; @override String get actualTableName => $name; static const String $name = 'messages'; @override VerificationContext validateIntegrity( Insertable instance, { bool isInserting = false, }) { final context = VerificationContext(); final data = instance.toColumns(true); if (data.containsKey('id')) { context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); } if (data.containsKey('account_scope')) { context.handle( _accountScopeMeta, accountScope.isAcceptableOrUnknown( data['account_scope']!, _accountScopeMeta, ), ); } else if (isInserting) { context.missing(_accountScopeMeta); } if (data.containsKey('peer_pubkey')) { context.handle( _peerPubkeyMeta, peerPubkey.isAcceptableOrUnknown(data['peer_pubkey']!, _peerPubkeyMeta), ); } else if (isInserting) { context.missing(_peerPubkeyMeta); } if (data.containsKey('from_pubkey')) { context.handle( _fromPubkeyMeta, fromPubkey.isAcceptableOrUnknown(data['from_pubkey']!, _fromPubkeyMeta), ); } else if (isInserting) { context.missing(_fromPubkeyMeta); } if (data.containsKey('body')) { context.handle( _bodyMeta, body.isAcceptableOrUnknown(data['body']!, _bodyMeta), ); } else if (isInserting) { context.missing(_bodyMeta); } if (data.containsKey('sent_at')) { context.handle( _sentAtMeta, sentAt.isAcceptableOrUnknown(data['sent_at']!, _sentAtMeta), ); } else if (isInserting) { context.missing(_sentAtMeta); } return context; } @override Set get $primaryKey => {id}; @override List> get uniqueKeys => [ {accountScope, peerPubkey, fromPubkey, sentAt, body}, ]; @override Message map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; return Message( id: attachedDatabase.typeMapping.read( DriftSqlType.int, data['${effectivePrefix}id'], )!, accountScope: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}account_scope'], )!, peerPubkey: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}peer_pubkey'], )!, fromPubkey: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}from_pubkey'], )!, body: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}body'], )!, sentAt: attachedDatabase.typeMapping.read( DriftSqlType.int, data['${effectivePrefix}sent_at'], )!, ); } @override $MessagesTable createAlias(String alias) { return $MessagesTable(attachedDatabase, alias); } } class Message extends DataClass implements Insertable { final int id; final String accountScope; final String peerPubkey; final String fromPubkey; final String body; /// Milliseconds since epoch — the message's own timestamp (NIP-17), used for /// ordering and for the read/unread mark. final int sentAt; const Message({ required this.id, required this.accountScope, required this.peerPubkey, required this.fromPubkey, required this.body, required this.sentAt, }); @override Map toColumns(bool nullToAbsent) { final map = {}; map['id'] = Variable(id); map['account_scope'] = Variable(accountScope); map['peer_pubkey'] = Variable(peerPubkey); map['from_pubkey'] = Variable(fromPubkey); map['body'] = Variable(body); map['sent_at'] = Variable(sentAt); return map; } MessagesCompanion toCompanion(bool nullToAbsent) { return MessagesCompanion( id: Value(id), accountScope: Value(accountScope), peerPubkey: Value(peerPubkey), fromPubkey: Value(fromPubkey), body: Value(body), sentAt: Value(sentAt), ); } factory Message.fromJson( Map json, { ValueSerializer? serializer, }) { serializer ??= driftRuntimeOptions.defaultSerializer; return Message( id: serializer.fromJson(json['id']), accountScope: serializer.fromJson(json['accountScope']), peerPubkey: serializer.fromJson(json['peerPubkey']), fromPubkey: serializer.fromJson(json['fromPubkey']), body: serializer.fromJson(json['body']), sentAt: serializer.fromJson(json['sentAt']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { 'id': serializer.toJson(id), 'accountScope': serializer.toJson(accountScope), 'peerPubkey': serializer.toJson(peerPubkey), 'fromPubkey': serializer.toJson(fromPubkey), 'body': serializer.toJson(body), 'sentAt': serializer.toJson(sentAt), }; } Message copyWith({ int? id, String? accountScope, String? peerPubkey, String? fromPubkey, String? body, int? sentAt, }) => Message( id: id ?? this.id, accountScope: accountScope ?? this.accountScope, peerPubkey: peerPubkey ?? this.peerPubkey, fromPubkey: fromPubkey ?? this.fromPubkey, body: body ?? this.body, sentAt: sentAt ?? this.sentAt, ); Message copyWithCompanion(MessagesCompanion data) { return Message( id: data.id.present ? data.id.value : this.id, accountScope: data.accountScope.present ? data.accountScope.value : this.accountScope, peerPubkey: data.peerPubkey.present ? data.peerPubkey.value : this.peerPubkey, fromPubkey: data.fromPubkey.present ? data.fromPubkey.value : this.fromPubkey, body: data.body.present ? data.body.value : this.body, sentAt: data.sentAt.present ? data.sentAt.value : this.sentAt, ); } @override String toString() { return (StringBuffer('Message(') ..write('id: $id, ') ..write('accountScope: $accountScope, ') ..write('peerPubkey: $peerPubkey, ') ..write('fromPubkey: $fromPubkey, ') ..write('body: $body, ') ..write('sentAt: $sentAt') ..write(')')) .toString(); } @override int get hashCode => Object.hash(id, accountScope, peerPubkey, fromPubkey, body, sentAt); @override bool operator ==(Object other) => identical(this, other) || (other is Message && other.id == this.id && other.accountScope == this.accountScope && other.peerPubkey == this.peerPubkey && other.fromPubkey == this.fromPubkey && other.body == this.body && other.sentAt == this.sentAt); } class MessagesCompanion extends UpdateCompanion { final Value id; final Value accountScope; final Value peerPubkey; final Value fromPubkey; final Value body; final Value sentAt; const MessagesCompanion({ this.id = const Value.absent(), this.accountScope = const Value.absent(), this.peerPubkey = const Value.absent(), this.fromPubkey = const Value.absent(), this.body = const Value.absent(), this.sentAt = const Value.absent(), }); MessagesCompanion.insert({ this.id = const Value.absent(), required String accountScope, required String peerPubkey, required String fromPubkey, required String body, required int sentAt, }) : accountScope = Value(accountScope), peerPubkey = Value(peerPubkey), fromPubkey = Value(fromPubkey), body = Value(body), sentAt = Value(sentAt); static Insertable custom({ Expression? id, Expression? accountScope, Expression? peerPubkey, Expression? fromPubkey, Expression? body, Expression? sentAt, }) { return RawValuesInsertable({ if (id != null) 'id': id, if (accountScope != null) 'account_scope': accountScope, if (peerPubkey != null) 'peer_pubkey': peerPubkey, if (fromPubkey != null) 'from_pubkey': fromPubkey, if (body != null) 'body': body, if (sentAt != null) 'sent_at': sentAt, }); } MessagesCompanion copyWith({ Value? id, Value? accountScope, Value? peerPubkey, Value? fromPubkey, Value? body, Value? sentAt, }) { return MessagesCompanion( id: id ?? this.id, accountScope: accountScope ?? this.accountScope, peerPubkey: peerPubkey ?? this.peerPubkey, fromPubkey: fromPubkey ?? this.fromPubkey, body: body ?? this.body, sentAt: sentAt ?? this.sentAt, ); } @override Map toColumns(bool nullToAbsent) { final map = {}; if (id.present) { map['id'] = Variable(id.value); } if (accountScope.present) { map['account_scope'] = Variable(accountScope.value); } if (peerPubkey.present) { map['peer_pubkey'] = Variable(peerPubkey.value); } if (fromPubkey.present) { map['from_pubkey'] = Variable(fromPubkey.value); } if (body.present) { map['body'] = Variable(body.value); } if (sentAt.present) { map['sent_at'] = Variable(sentAt.value); } return map; } @override String toString() { return (StringBuffer('MessagesCompanion(') ..write('id: $id, ') ..write('accountScope: $accountScope, ') ..write('peerPubkey: $peerPubkey, ') ..write('fromPubkey: $fromPubkey, ') ..write('body: $body, ') ..write('sentAt: $sentAt') ..write(')')) .toString(); } } abstract class _$ChatDatabase extends GeneratedDatabase { _$ChatDatabase(QueryExecutor e) : super(e); $ChatDatabaseManager get managers => $ChatDatabaseManager(this); late final $MessagesTable messages = $MessagesTable(this); late final Index messagesByConversation = Index( 'messages_by_conversation', 'CREATE INDEX messages_by_conversation ON messages (account_scope, peer_pubkey, sent_at)', ); @override Iterable> get allTables => allSchemaEntities.whereType>(); @override List get allSchemaEntities => [ messages, messagesByConversation, ]; } typedef $$MessagesTableCreateCompanionBuilder = MessagesCompanion Function({ Value id, required String accountScope, required String peerPubkey, required String fromPubkey, required String body, required int sentAt, }); typedef $$MessagesTableUpdateCompanionBuilder = MessagesCompanion Function({ Value id, Value accountScope, Value peerPubkey, Value fromPubkey, Value body, Value sentAt, }); class $$MessagesTableFilterComposer extends Composer<_$ChatDatabase, $MessagesTable> { $$MessagesTableFilterComposer({ required super.$db, required super.$table, super.joinBuilder, super.$addJoinBuilderToRootComposer, super.$removeJoinBuilderFromRootComposer, }); ColumnFilters get id => $composableBuilder( column: $table.id, builder: (column) => ColumnFilters(column), ); ColumnFilters get accountScope => $composableBuilder( column: $table.accountScope, builder: (column) => ColumnFilters(column), ); ColumnFilters get peerPubkey => $composableBuilder( column: $table.peerPubkey, builder: (column) => ColumnFilters(column), ); ColumnFilters get fromPubkey => $composableBuilder( column: $table.fromPubkey, builder: (column) => ColumnFilters(column), ); ColumnFilters get body => $composableBuilder( column: $table.body, builder: (column) => ColumnFilters(column), ); ColumnFilters get sentAt => $composableBuilder( column: $table.sentAt, builder: (column) => ColumnFilters(column), ); } class $$MessagesTableOrderingComposer extends Composer<_$ChatDatabase, $MessagesTable> { $$MessagesTableOrderingComposer({ required super.$db, required super.$table, super.joinBuilder, super.$addJoinBuilderToRootComposer, super.$removeJoinBuilderFromRootComposer, }); ColumnOrderings get id => $composableBuilder( column: $table.id, builder: (column) => ColumnOrderings(column), ); ColumnOrderings get accountScope => $composableBuilder( column: $table.accountScope, builder: (column) => ColumnOrderings(column), ); ColumnOrderings get peerPubkey => $composableBuilder( column: $table.peerPubkey, builder: (column) => ColumnOrderings(column), ); ColumnOrderings get fromPubkey => $composableBuilder( column: $table.fromPubkey, builder: (column) => ColumnOrderings(column), ); ColumnOrderings get body => $composableBuilder( column: $table.body, builder: (column) => ColumnOrderings(column), ); ColumnOrderings get sentAt => $composableBuilder( column: $table.sentAt, builder: (column) => ColumnOrderings(column), ); } class $$MessagesTableAnnotationComposer extends Composer<_$ChatDatabase, $MessagesTable> { $$MessagesTableAnnotationComposer({ required super.$db, required super.$table, super.joinBuilder, super.$addJoinBuilderToRootComposer, super.$removeJoinBuilderFromRootComposer, }); GeneratedColumn get id => $composableBuilder(column: $table.id, builder: (column) => column); GeneratedColumn get accountScope => $composableBuilder( column: $table.accountScope, builder: (column) => column, ); GeneratedColumn get peerPubkey => $composableBuilder( column: $table.peerPubkey, builder: (column) => column, ); GeneratedColumn get fromPubkey => $composableBuilder( column: $table.fromPubkey, builder: (column) => column, ); GeneratedColumn get body => $composableBuilder(column: $table.body, builder: (column) => column); GeneratedColumn get sentAt => $composableBuilder(column: $table.sentAt, builder: (column) => column); } class $$MessagesTableTableManager extends RootTableManager< _$ChatDatabase, $MessagesTable, Message, $$MessagesTableFilterComposer, $$MessagesTableOrderingComposer, $$MessagesTableAnnotationComposer, $$MessagesTableCreateCompanionBuilder, $$MessagesTableUpdateCompanionBuilder, (Message, BaseReferences<_$ChatDatabase, $MessagesTable, Message>), Message, PrefetchHooks Function() > { $$MessagesTableTableManager(_$ChatDatabase db, $MessagesTable table) : super( TableManagerState( db: db, table: table, createFilteringComposer: () => $$MessagesTableFilterComposer($db: db, $table: table), createOrderingComposer: () => $$MessagesTableOrderingComposer($db: db, $table: table), createComputedFieldComposer: () => $$MessagesTableAnnotationComposer($db: db, $table: table), updateCompanionCallback: ({ Value id = const Value.absent(), Value accountScope = const Value.absent(), Value peerPubkey = const Value.absent(), Value fromPubkey = const Value.absent(), Value body = const Value.absent(), Value sentAt = const Value.absent(), }) => MessagesCompanion( id: id, accountScope: accountScope, peerPubkey: peerPubkey, fromPubkey: fromPubkey, body: body, sentAt: sentAt, ), createCompanionCallback: ({ Value id = const Value.absent(), required String accountScope, required String peerPubkey, required String fromPubkey, required String body, required int sentAt, }) => MessagesCompanion.insert( id: id, accountScope: accountScope, peerPubkey: peerPubkey, fromPubkey: fromPubkey, body: body, sentAt: sentAt, ), withReferenceMapper: (p0) => p0 .map((e) => (e.readTable(table), BaseReferences(db, table, e))) .toList(), prefetchHooksCallback: null, ), ); } typedef $$MessagesTableProcessedTableManager = ProcessedTableManager< _$ChatDatabase, $MessagesTable, Message, $$MessagesTableFilterComposer, $$MessagesTableOrderingComposer, $$MessagesTableAnnotationComposer, $$MessagesTableCreateCompanionBuilder, $$MessagesTableUpdateCompanionBuilder, (Message, BaseReferences<_$ChatDatabase, $MessagesTable, Message>), Message, PrefetchHooks Function() >; class $ChatDatabaseManager { final _$ChatDatabase _db; $ChatDatabaseManager(this._db); $$MessagesTableTableManager get messages => $$MessagesTableTableManager(_db, _db.messages); }