2024-06-23 04:29:07 +00:00
// GENERATED CODE - DO NOT MODIFY BY HAND
2024-06-27 16:05:43 +00:00
part of ' events.dart ' ;
2024-06-23 04:29:07 +00:00
// **************************************************************************
// FloorGenerator
// **************************************************************************
abstract class $MessageHistoryDbBuilderContract {
/// Adds migrations to the builder.
$MessageHistoryDbBuilderContract addMigrations ( List < Migration > migrations ) ;
/// Adds a database [Callback] to the builder.
$MessageHistoryDbBuilderContract addCallback ( Callback callback ) ;
/// Creates the database and initializes it.
Future < MessageHistoryDb > build ( ) ;
}
// ignore: avoid_classes_with_only_static_members
class $FloorMessageHistoryDb {
/// Creates a database builder for a persistent database.
/// Once a database is built, you should keep a reference to it and re-use it.
static $MessageHistoryDbBuilderContract databaseBuilder ( String name ) = >
_ $MessageHistoryDbBuilder ( name ) ;
/// Creates a database builder for an in memory database.
/// Information stored in an in memory database disappears when the process is killed.
/// Once a database is built, you should keep a reference to it and re-use it.
static $MessageHistoryDbBuilderContract inMemoryDatabaseBuilder ( ) = >
_ $MessageHistoryDbBuilder ( null ) ;
}
class _ $MessageHistoryDbBuilder implements $MessageHistoryDbBuilderContract {
_ $MessageHistoryDbBuilder ( this . name ) ;
final String ? name ;
final List < Migration > _migrations = [ ] ;
Callback ? _callback ;
@ override
$MessageHistoryDbBuilderContract addMigrations ( List < Migration > migrations ) {
_migrations . addAll ( migrations ) ;
return this ;
}
@ override
$MessageHistoryDbBuilderContract addCallback ( Callback callback ) {
_callback = callback ;
return this ;
}
@ override
Future < MessageHistoryDb > build ( ) async {
final path = name ! = null
? await sqfliteDatabaseFactory . getDatabasePath ( name ! )
: ' :memory: ' ;
final database = _ $MessageHistoryDb ( ) ;
database . database = await database . open (
path ,
_migrations ,
_callback ,
) ;
return database ;
}
}
class _ $MessageHistoryDb extends MessageHistoryDb {
_ $MessageHistoryDb ( [ StreamController < String > ? listener ] ) {
changeListener = listener ? ? StreamController < String > . broadcast ( ) ;
}
2024-06-27 16:05:43 +00:00
LocalEventDao ? _localEventsInstance ;
2024-06-23 04:29:07 +00:00
Future < sqflite . Database > open (
String path ,
List < Migration > migrations , [
Callback ? callback ,
] ) async {
final databaseOptions = sqflite . OpenDatabaseOptions (
2024-06-27 16:05:43 +00:00
version: 2 ,
2024-06-23 04:29:07 +00:00
onConfigure: ( database ) async {
await database . execute ( ' PRAGMA foreign_keys = ON ' ) ;
await callback ? . onConfigure ? . call ( database ) ;
} ,
onOpen: ( database ) async {
await callback ? . onOpen ? . call ( database ) ;
} ,
onUpgrade: ( database , startVersion , endVersion ) async {
await MigrationAdapter . runMigrations (
database , startVersion , endVersion , migrations ) ;
await callback ? . onUpgrade ? . call ( database , startVersion , endVersion ) ;
} ,
onCreate: ( database , version ) async {
await database . execute (
2024-06-27 16:05:43 +00:00
' CREATE TABLE IF NOT EXISTS `LocalEvent` (`id` INTEGER NOT NULL, `data` TEXT NOT NULL, `channelId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY (`id`)) ' ) ;
2024-06-23 04:29:07 +00:00
await callback ? . onCreate ? . call ( database , version ) ;
} ,
) ;
return sqfliteDatabaseFactory . openDatabase ( path , options: databaseOptions ) ;
}
@ override
2024-06-27 16:05:43 +00:00
LocalEventDao get localEvents {
return _localEventsInstance ? ? = _ $LocalEventDao ( database , changeListener ) ;
2024-06-23 04:29:07 +00:00
}
}
2024-06-27 16:05:43 +00:00
class _ $LocalEventDao extends LocalEventDao {
_ $LocalEventDao (
2024-06-23 04:29:07 +00:00
this . database ,
this . changeListener ,
) : _queryAdapter = QueryAdapter ( database ) ,
2024-06-27 16:05:43 +00:00
_localEventInsertionAdapter = InsertionAdapter (
2024-06-23 04:29:07 +00:00
database ,
2024-06-27 16:05:43 +00:00
' LocalEvent ' ,
( LocalEvent item ) = > < String , Object ? > {
2024-06-23 05:27:21 +00:00
' id ' : item . id ,
2024-06-27 16:05:43 +00:00
' data ' : _remoteEventConverter . encode ( item . data ) ,
' channelId ' : item . channelId ,
' createdAt ' : _dateTimeConverter . encode ( item . createdAt )
2024-06-23 05:27:21 +00:00
} ) ,
2024-06-27 16:05:43 +00:00
_localEventUpdateAdapter = UpdateAdapter (
2024-06-23 05:27:21 +00:00
database ,
2024-06-27 16:05:43 +00:00
' LocalEvent ' ,
2024-06-23 05:27:21 +00:00
[ ' id ' ] ,
2024-06-27 16:05:43 +00:00
( LocalEvent item ) = > < String , Object ? > {
2024-06-23 04:29:07 +00:00
' id ' : item . id ,
2024-06-27 16:05:43 +00:00
' data ' : _remoteEventConverter . encode ( item . data ) ,
' channelId ' : item . channelId ,
' createdAt ' : _dateTimeConverter . encode ( item . createdAt )
2024-06-23 04:29:07 +00:00
} ) ;
final sqflite . DatabaseExecutor database ;
final StreamController < String > changeListener ;
final QueryAdapter _queryAdapter ;
2024-06-27 16:05:43 +00:00
final InsertionAdapter < LocalEvent > _localEventInsertionAdapter ;
2024-06-23 04:29:07 +00:00
2024-06-27 16:05:43 +00:00
final UpdateAdapter < LocalEvent > _localEventUpdateAdapter ;
2024-06-23 05:27:21 +00:00
@ override
Future < int ? > countByChannel ( int channelId ) async {
return _queryAdapter . query (
2024-06-27 16:05:43 +00:00
' SELECT COUNT(id) FROM LocalEvent WHERE channelId = ?1 ' ,
2024-06-23 05:27:21 +00:00
mapper: ( Map < String , Object ? > row ) = > row . values . first as int ,
arguments: [ channelId ] ) ;
}
2024-06-23 04:29:07 +00:00
@ override
2024-06-27 16:05:43 +00:00
Future < LocalEvent ? > findById ( int id ) async {
return _queryAdapter . query ( ' SELECT * FROM LocalEvent WHERE id = ?1 ' ,
mapper: ( Map < String , Object ? > row ) = > LocalEvent (
row [ ' id ' ] as int ,
_remoteEventConverter . decode ( row [ ' data ' ] as String ) ,
row [ ' channelId ' ] as int ,
_dateTimeConverter . decode ( row [ ' createdAt ' ] as int ) ) ,
arguments: [ id ] ) ;
}
@ override
Future < List < LocalEvent > > findAllByChannel ( int channelId ) async {
2024-06-23 04:29:07 +00:00
return _queryAdapter . queryList (
2024-06-27 16:05:43 +00:00
' SELECT * FROM LocalEvent WHERE channelId = ?1 ORDER BY createdAt DESC ' ,
mapper: ( Map < String , Object ? > row ) = > LocalEvent (
2024-06-23 05:27:21 +00:00
row [ ' id ' ] as int ,
2024-06-27 16:05:43 +00:00
_remoteEventConverter . decode ( row [ ' data ' ] as String ) ,
row [ ' channelId ' ] as int ,
_dateTimeConverter . decode ( row [ ' createdAt ' ] as int ) ) ,
2024-06-23 05:27:21 +00:00
arguments: [ channelId ] ) ;
}
@ override
2024-06-27 16:05:43 +00:00
Future < LocalEvent ? > findLastByChannel ( int channelId ) async {
2024-06-23 05:27:21 +00:00
return _queryAdapter . query (
2024-06-27 16:05:43 +00:00
' SELECT * FROM LocalEvent WHERE channelId = ?1 ORDER BY createdAt DESC LIMIT 1 ' ,
mapper: ( Map < String , Object ? > row ) = > LocalEvent ( row [ ' id ' ] as int , _remoteEventConverter . decode ( row [ ' data ' ] as String ) , row [ ' channelId ' ] as int , _dateTimeConverter . decode ( row [ ' createdAt ' ] as int ) ) ,
2024-06-23 05:27:21 +00:00
arguments: [ channelId ] ) ;
}
@ override
Future < void > delete ( int id ) async {
2024-06-27 16:05:43 +00:00
await _queryAdapter
. queryNoReturn ( ' DELETE FROM LocalEvent WHERE id = ?1 ' , arguments: [ id ] ) ;
2024-06-23 05:27:21 +00:00
}
@ override
2024-06-27 16:05:43 +00:00
Future < List < LocalEvent > > deleteByChannel ( int channelId ) async {
2024-06-23 05:27:21 +00:00
return _queryAdapter . queryList (
2024-06-27 16:05:43 +00:00
' DELETE FROM LocalEvent WHERE channelId = ?1 ' ,
mapper: ( Map < String , Object ? > row ) = > LocalEvent (
2024-06-23 04:29:07 +00:00
row [ ' id ' ] as int ,
2024-06-27 16:05:43 +00:00
_remoteEventConverter . decode ( row [ ' data ' ] as String ) ,
row [ ' channelId ' ] as int ,
_dateTimeConverter . decode ( row [ ' createdAt ' ] as int ) ) ,
2024-06-23 04:29:07 +00:00
arguments: [ channelId ] ) ;
}
@ override
2024-06-27 16:05:43 +00:00
Future < void > wipeLocalEvents ( ) async {
await _queryAdapter . queryNoReturn ( ' DELETE FROM LocalEvent ' ) ;
2024-06-23 04:29:07 +00:00
}
@ override
2024-06-27 16:05:43 +00:00
Future < void > insert ( LocalEvent m ) async {
await _localEventInsertionAdapter . insert ( m , OnConflictStrategy . replace ) ;
2024-06-23 04:29:07 +00:00
}
@ override
2024-06-27 16:05:43 +00:00
Future < void > insertBulk ( List < LocalEvent > m ) async {
await _localEventInsertionAdapter . insertList ( m , OnConflictStrategy . replace ) ;
2024-06-23 04:29:07 +00:00
}
2024-06-23 05:27:21 +00:00
@ override
2024-06-27 16:05:43 +00:00
Future < void > update ( LocalEvent m ) async {
await _localEventUpdateAdapter . update ( m , OnConflictStrategy . replace ) ;
2024-06-23 05:27:21 +00:00
}
2024-06-23 04:29:07 +00:00
}
// ignore_for_file: unused_element
2024-06-27 16:05:43 +00:00
final _dateTimeConverter = DateTimeConverter ( ) ;
final _remoteEventConverter = RemoteEventConverter ( ) ;