2024-08-07 19:30:20 +01:00
|
|
|
|
2024-08-14 15:29:16 +01:00
|
|
|
import { Dexie } from 'Dexie';
|
2024-08-27 10:15:00 +01:00
|
|
|
import { DexieMessageTable, messageTableColumn, MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
|
|
|
|
import { DexieMembersTableSchema, MemberTableColumn } from 'src/app/infra/database/dexie/instance/chat/schema/members';
|
|
|
|
|
import { DexieRoomsTable, RoomTableColumn } from 'src/app/infra/database/dexie/instance/chat/schema/room';
|
|
|
|
|
import { DexieTypingsTable, TypingTableColumn } from 'src/app/infra/database/dexie/instance/chat/schema/typing';
|
|
|
|
|
import { MessageEntity } from 'src/app/core/chat/entity/message';
|
|
|
|
|
import { AttachmentTableColumn, DexieAttachmentsTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/attachment';
|
2024-10-07 13:27:49 +01:00
|
|
|
import { DexieDistributionTable, DistributionTable, DistributionTableColumn } from './schema/destribution';
|
|
|
|
|
import { BoldTableColumn, DexieBoldTable } from './schema/bold';
|
|
|
|
|
import { DexieUserPhotoTable, UserPhotoTable, UserPhotoTableColumn } from './schema/user-foto';
|
2024-08-17 22:05:57 +01:00
|
|
|
// import FDBFactory from 'fake-indexeddb/lib/FDBFactory';
|
|
|
|
|
// import FDBKeyRange from 'fake-indexeddb/lib/FDBKeyRange';
|
|
|
|
|
|
2024-08-07 19:30:20 +01:00
|
|
|
|
|
|
|
|
// Database declaration (move this to its own module also)
|
2024-09-18 15:24:50 +01:00
|
|
|
export const chatDatabase = new Dexie('chat-database-v3',{
|
2024-08-17 22:05:57 +01:00
|
|
|
// indexedDB: new FDBFactory,
|
|
|
|
|
// IDBKeyRange: FDBKeyRange, // Mocking IDBKeyRange
|
|
|
|
|
}) as Dexie & {
|
2024-08-07 19:30:20 +01:00
|
|
|
message: DexieMessageTable,
|
|
|
|
|
members: DexieMembersTableSchema,
|
2024-08-14 15:29:16 +01:00
|
|
|
room: DexieRoomsTable,
|
|
|
|
|
typing: DexieTypingsTable,
|
2024-08-13 10:52:35 +01:00
|
|
|
attachment: DexieAttachmentsTableSchema,
|
2024-08-30 12:41:50 +01:00
|
|
|
distribution: DexieDistributionTable,
|
2024-09-06 14:38:30 +01:00
|
|
|
bold: DexieBoldTable,
|
|
|
|
|
userPhoto: DexieUserPhotoTable
|
2024-08-07 19:30:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
chatDatabase.version(1).stores({
|
|
|
|
|
message: messageTableColumn,
|
|
|
|
|
members: MemberTableColumn,
|
|
|
|
|
room: RoomTableColumn,
|
2024-08-13 10:52:35 +01:00
|
|
|
typing: TypingTableColumn,
|
2024-08-30 12:41:50 +01:00
|
|
|
attachment: AttachmentTableColumn,
|
|
|
|
|
distribution: DistributionTableColumn,
|
2024-09-06 14:38:30 +01:00
|
|
|
bold:BoldTableColumn,
|
2024-09-09 10:28:53 +01:00
|
|
|
userPhoto: UserPhotoTableColumn
|
2024-08-07 19:30:20 +01:00
|
|
|
});
|
2024-08-07 20:23:33 +01:00
|
|
|
|
|
|
|
|
chatDatabase.message.mapToClass(MessageEntity)
|
2024-08-26 14:47:03 +01:00
|
|
|
// Apply in-memory storage
|