feat: use indexDB instead of array filter
This commit is contained in:
18
composables/db.ts
Normal file
18
composables/db.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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()
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user