Files
cook/composables/db.ts
2023-07-30 18:25:54 +08:00

19 lines
449 B
TypeScript

import { useStorage } from '@vueuse/core'
import { lastDbUpdated, namespace } from '~/constants'
export function useIndexedDB() {
const dbUpdated = useStorage(`${namespace}:lastDbUpdated`, lastDbUpdated)
return {
// db,
// initDb,
init: async () => {
const count = await db.recipes.count()
if (!count || dbUpdated.value !== lastDbUpdated) {
dbUpdated.value = lastDbUpdated
initDb()
}
},
}
}