diff options
Diffstat (limited to 'src/client/db')
| -rw-r--r-- | src/client/db/index.test.ts | 1 | ||||
| -rw-r--r-- | src/client/db/index.ts | 12 | ||||
| -rw-r--r-- | src/client/db/repositories.test.ts | 16 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/client/db/index.test.ts b/src/client/db/index.test.ts index 0dd3758..32011b5 100644 --- a/src/client/db/index.test.ts +++ b/src/client/db/index.test.ts @@ -64,6 +64,7 @@ describe("KiokuDatabase", () => { userId: "user-1", name: "Test Deck", description: "A test deck", + defaultNoteTypeId: null, createdAt: new Date("2024-01-01"), updatedAt: new Date("2024-01-01"), deletedAt: null, diff --git a/src/client/db/index.ts b/src/client/db/index.ts index 50d8bbd..a3fbd49 100644 --- a/src/client/db/index.ts +++ b/src/client/db/index.ts @@ -77,6 +77,7 @@ export interface LocalDeck { userId: string; name: string; description: string | null; + defaultNoteTypeId: string | null; createdAt: Date; updatedAt: Date; deletedAt: Date | null; @@ -251,6 +252,17 @@ export class KiokuDatabase extends Dexie { notes: "id, deckId, noteTypeId, updatedAt", noteFieldValues: "id, noteId, noteFieldTypeId, updatedAt", }); + + // Version 4: Add defaultNoteTypeId to decks (no index change needed) + this.version(4).stores({ + decks: "id, userId, updatedAt", + cards: "id, deckId, noteId, updatedAt, due, state", + reviewLogs: "id, cardId, userId, reviewedAt", + noteTypes: "id, userId, updatedAt", + noteFieldTypes: "id, noteTypeId, updatedAt", + notes: "id, deckId, noteTypeId, updatedAt", + noteFieldValues: "id, noteId, noteFieldTypeId, updatedAt", + }); } } diff --git a/src/client/db/repositories.test.ts b/src/client/db/repositories.test.ts index b461990..6a77760 100644 --- a/src/client/db/repositories.test.ts +++ b/src/client/db/repositories.test.ts @@ -33,6 +33,7 @@ describe("localDeckRepository", () => { userId: "user-1", name: "Test Deck", description: "A test deck", + defaultNoteTypeId: null, }); expect(deck.id).toBeDefined(); @@ -51,6 +52,7 @@ describe("localDeckRepository", () => { userId: "user-1", name: "Test Deck", description: null, + defaultNoteTypeId: null, }); const found = await db.decks.get(created.id); @@ -64,6 +66,7 @@ describe("localDeckRepository", () => { userId: "user-1", name: "Test Deck", description: null, + defaultNoteTypeId: null, }); const found = await localDeckRepository.findById(created.id); @@ -82,16 +85,19 @@ describe("localDeckRepository", () => { userId: "user-1", name: "Deck 1", description: null, + defaultNoteTypeId: null, }); await localDeckRepository.create({ userId: "user-1", name: "Deck 2", description: null, + defaultNoteTypeId: null, }); await localDeckRepository.create({ userId: "user-2", name: "Other User Deck", description: null, + defaultNoteTypeId: null, }); const decks = await localDeckRepository.findByUserId("user-1"); @@ -104,6 +110,7 @@ describe("localDeckRepository", () => { userId: "user-1", name: "Deleted Deck", description: null, + defaultNoteTypeId: null, }); await localDeckRepository.delete(deck.id); @@ -118,6 +125,7 @@ describe("localDeckRepository", () => { userId: "user-1", name: "Original Name", description: null, + defaultNoteTypeId: null, }); const updated = await localDeckRepository.update(deck.id, { @@ -147,6 +155,7 @@ describe("localDeckRepository", () => { userId: "user-1", name: "Test Deck", description: null, + defaultNoteTypeId: null, }); const result = await localDeckRepository.delete(deck.id); @@ -169,11 +178,13 @@ describe("localDeckRepository", () => { userId: "user-1", name: "Unsynced", description: null, + defaultNoteTypeId: null, }); const deck2 = await localDeckRepository.create({ userId: "user-1", name: "Synced", description: null, + defaultNoteTypeId: null, }); await localDeckRepository.markSynced(deck2.id, 1); @@ -189,6 +200,7 @@ describe("localDeckRepository", () => { userId: "user-1", name: "Test", description: null, + defaultNoteTypeId: null, }); await localDeckRepository.markSynced(deck.id, 5); @@ -212,6 +224,7 @@ describe("localCardRepository", () => { userId: "user-1", name: "Test Deck", description: null, + defaultNoteTypeId: null, }); deckId = deck.id; }); @@ -411,6 +424,7 @@ describe("localReviewLogRepository", () => { userId: "user-1", name: "Test Deck", description: null, + defaultNoteTypeId: null, }); deckId = deck.id; @@ -935,6 +949,7 @@ describe("localNoteRepository", () => { userId: "user-1", name: "Test Deck", description: null, + defaultNoteTypeId: null, }); deckId = deck.id; @@ -1094,6 +1109,7 @@ describe("localNoteFieldValueRepository", () => { userId: "user-1", name: "Test Deck", description: null, + defaultNoteTypeId: null, }); const noteType = await localNoteTypeRepository.create({ |
