feat: initial sketch with AI
This commit is contained in:
+42
-7
@@ -1,12 +1,47 @@
|
||||
import Dexie from 'dexie';
|
||||
import Dexie, { type Table } from 'dexie'
|
||||
import type { List, ListItem } from '@/types/list'
|
||||
|
||||
export const db = new Dexie('dttmrdb')
|
||||
export interface LocalList extends List {
|
||||
pendingSync?: boolean
|
||||
}
|
||||
|
||||
db.version(1).stores({
|
||||
lists: '++id, uuid, title',
|
||||
export interface LocalListItem extends ListItem {
|
||||
pendingSync?: boolean
|
||||
}
|
||||
|
||||
listItems: '++id, uuid, title, isChecked',
|
||||
export type SyncOperationType =
|
||||
| 'createList'
|
||||
| 'createListItem'
|
||||
| 'updateListItem'
|
||||
| 'setListItemCompleted'
|
||||
| 'addUserToList'
|
||||
| 'removeUserFromList'
|
||||
|
||||
syncQueue: '++id, action, endpoint, createdAt',
|
||||
})
|
||||
export interface SyncQueueEntry {
|
||||
id?: number
|
||||
type: SyncOperationType
|
||||
payload: unknown
|
||||
localListId?: string
|
||||
localListItemId?: string
|
||||
createdAt: number
|
||||
attempts: number
|
||||
lastError?: string
|
||||
}
|
||||
|
||||
class AppDatabase extends Dexie {
|
||||
lists!: Table<LocalList, string>
|
||||
listItems!: Table<LocalListItem, string>
|
||||
syncQueue!: Table<SyncQueueEntry, number>
|
||||
|
||||
constructor() {
|
||||
super('dttmrdb')
|
||||
|
||||
this.version(1).stores({
|
||||
lists: 'id, name, pendingSync',
|
||||
listItems: 'id, list_id, title, is_completed, pendingSync',
|
||||
syncQueue: '++id, type, createdAt',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const db = new AppDatabase()
|
||||
|
||||
Reference in New Issue
Block a user