Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 1x 1x 1x 1x 1x | import Dexie, { type Table } from 'dexie'
import type { ShoppingList, Item } from '../types'
export interface CachedList extends ShoppingList {
_savedAt: number
}
export interface CachedItem extends Item {
_savedAt: number
}
export interface LocalClock {
listId: string
deviceId: string
counter: number
}
export interface PendingList {
tempId: string
name: string
emoji: string
createdAt: number
}
class ListMeCacheDb extends Dexie {
lists!: Table<CachedList, string>
items!: Table<CachedItem, string>
localClocks!: Table<LocalClock, [string, string]>
pendingLists!: Table<PendingList, string>
constructor() {
super('listme-cache')
this.version(1).stores({
lists: 'id, _savedAt',
items: 'id, listId, _savedAt',
})
this.version(2).stores({
lists: 'id, _savedAt',
items: 'id, listId, _savedAt',
localClocks: '[listId+deviceId]',
})
this.version(3).stores({
lists: 'id, _savedAt',
items: 'id, listId, _savedAt',
localClocks: '[listId+deviceId]',
pendingLists: 'tempId',
})
}
}
export const cacheDb = new ListMeCacheDb()
|