| 57 | } |
| 58 | |
| 59 | export const updateLocalCard = async ( |
| 60 | id: string, |
| 61 | updates: Partial<Pick<LocalCard, 'front' | 'back'>>, |
| 62 | ): Promise<number> => { |
| 63 | const card = await db.cards.get(id) |
| 64 | if (!card) throw new Error('Card not found for update') |
| 65 | const result = await db.cards.update(id, { |
| 66 | ...updates, |
| 67 | updatedAt: Date.now(), |
| 68 | synced: false, |
| 69 | }) |
| 70 | await db.collections.update(card.collectionId, { |
| 71 | updatedAt: Date.now(), |
| 72 | synced: false, |
| 73 | }) |
| 74 | return result |
| 75 | } |
| 76 | |
| 77 | export const deleteLocalCard = async (id: string): Promise<void> => { |
| 78 | const card = await db.cards.get(id) |