Offline Support
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
// GENERATED CODE DO NOT EDIT
|
||||
part of '../brick.g.dart';
|
||||
|
||||
Future<ChatMessage> _$ChatMessageFromSupabase(
|
||||
Map<String, dynamic> data, {
|
||||
required SupabaseProvider provider,
|
||||
OfflineFirstWithSupabaseRepository? repository,
|
||||
}) async {
|
||||
return ChatMessage(
|
||||
id: data['id'] as String,
|
||||
threadId: data['thread_id'] as String,
|
||||
senderId: data['sender_id'] as String,
|
||||
body: data['body'] as String,
|
||||
createdAt: DateTime.parse(data['created_at'] as String),
|
||||
);
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> _$ChatMessageToSupabase(
|
||||
ChatMessage instance, {
|
||||
required SupabaseProvider provider,
|
||||
OfflineFirstWithSupabaseRepository? repository,
|
||||
}) async {
|
||||
return {
|
||||
'id': instance.id,
|
||||
'thread_id': instance.threadId,
|
||||
'sender_id': instance.senderId,
|
||||
'body': instance.body,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
Future<ChatMessage> _$ChatMessageFromSqlite(
|
||||
Map<String, dynamic> data, {
|
||||
required SqliteProvider provider,
|
||||
OfflineFirstWithSupabaseRepository? repository,
|
||||
}) async {
|
||||
return ChatMessage(
|
||||
id: data['id'] as String,
|
||||
threadId: data['thread_id'] as String,
|
||||
senderId: data['sender_id'] as String,
|
||||
body: data['body'] as String,
|
||||
createdAt: DateTime.parse(data['created_at'] as String),
|
||||
)..primaryKey = data['_brick_id'] as int;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> _$ChatMessageToSqlite(
|
||||
ChatMessage instance, {
|
||||
required SqliteProvider provider,
|
||||
OfflineFirstWithSupabaseRepository? repository,
|
||||
}) async {
|
||||
return {
|
||||
'id': instance.id,
|
||||
'thread_id': instance.threadId,
|
||||
'sender_id': instance.senderId,
|
||||
'body': instance.body,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Construct a [ChatMessage]
|
||||
class ChatMessageAdapter extends OfflineFirstWithSupabaseAdapter<ChatMessage> {
|
||||
ChatMessageAdapter();
|
||||
|
||||
@override
|
||||
final supabaseTableName = 'chat_messages';
|
||||
@override
|
||||
final defaultToNull = true;
|
||||
@override
|
||||
final fieldsToSupabaseColumns = {
|
||||
'id': const RuntimeSupabaseColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'id',
|
||||
),
|
||||
'threadId': const RuntimeSupabaseColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'thread_id',
|
||||
),
|
||||
'senderId': const RuntimeSupabaseColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'sender_id',
|
||||
),
|
||||
'body': const RuntimeSupabaseColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'body',
|
||||
),
|
||||
'createdAt': const RuntimeSupabaseColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'created_at',
|
||||
),
|
||||
};
|
||||
@override
|
||||
final ignoreDuplicates = false;
|
||||
@override
|
||||
final uniqueFields = {};
|
||||
@override
|
||||
final Map<String, RuntimeSqliteColumnDefinition> fieldsToSqliteColumns = {
|
||||
'primaryKey': const RuntimeSqliteColumnDefinition(
|
||||
association: false,
|
||||
columnName: '_brick_id',
|
||||
iterable: false,
|
||||
type: int,
|
||||
),
|
||||
'id': const RuntimeSqliteColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'id',
|
||||
iterable: false,
|
||||
type: String,
|
||||
),
|
||||
'threadId': const RuntimeSqliteColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'thread_id',
|
||||
iterable: false,
|
||||
type: String,
|
||||
),
|
||||
'senderId': const RuntimeSqliteColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'sender_id',
|
||||
iterable: false,
|
||||
type: String,
|
||||
),
|
||||
'body': const RuntimeSqliteColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'body',
|
||||
iterable: false,
|
||||
type: String,
|
||||
),
|
||||
'createdAt': const RuntimeSqliteColumnDefinition(
|
||||
association: false,
|
||||
columnName: 'created_at',
|
||||
iterable: false,
|
||||
type: DateTime,
|
||||
),
|
||||
};
|
||||
@override
|
||||
Future<int?> primaryKeyByUniqueColumns(
|
||||
ChatMessage instance,
|
||||
DatabaseExecutor executor,
|
||||
) async => instance.primaryKey;
|
||||
@override
|
||||
final String tableName = 'ChatMessage';
|
||||
|
||||
@override
|
||||
Future<ChatMessage> fromSupabase(
|
||||
Map<String, dynamic> input, {
|
||||
required provider,
|
||||
covariant OfflineFirstWithSupabaseRepository? repository,
|
||||
}) async => await _$ChatMessageFromSupabase(
|
||||
input,
|
||||
provider: provider,
|
||||
repository: repository,
|
||||
);
|
||||
@override
|
||||
Future<Map<String, dynamic>> toSupabase(
|
||||
ChatMessage input, {
|
||||
required provider,
|
||||
covariant OfflineFirstWithSupabaseRepository? repository,
|
||||
}) async => await _$ChatMessageToSupabase(
|
||||
input,
|
||||
provider: provider,
|
||||
repository: repository,
|
||||
);
|
||||
@override
|
||||
Future<ChatMessage> fromSqlite(
|
||||
Map<String, dynamic> input, {
|
||||
required provider,
|
||||
covariant OfflineFirstWithSupabaseRepository? repository,
|
||||
}) async => await _$ChatMessageFromSqlite(
|
||||
input,
|
||||
provider: provider,
|
||||
repository: repository,
|
||||
);
|
||||
@override
|
||||
Future<Map<String, dynamic>> toSqlite(
|
||||
ChatMessage input, {
|
||||
required provider,
|
||||
covariant OfflineFirstWithSupabaseRepository? repository,
|
||||
}) async => await _$ChatMessageToSqlite(
|
||||
input,
|
||||
provider: provider,
|
||||
repository: repository,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user