@patwoz/react-query-cache-persistent-adapter-op-sqlite
Adapter for OP-SQLite to use react-query-cache-persistent.
Installation
bun add react-query-cache-persistent @patwoz/react-query-cache-persistent-adapter-op-sqlite
Example
Take also a look into the tests.
import { QueryClient } from '@tanstack/query-core'
import { createPersistentQueryCacheForOpSqlite } from '@patwoz/react-query-cache-persistent-adapter-op-sqlite'
import {
ANDROID_DATABASE_PATH,
IOS_LIBRARY_PATH,
open,
} from '@op-engineering/op-sqlite'
const db = open({
name: 'queryCache.sqlite3',
location: Platform.OS === 'ios' ? IOS_LIBRARY_PATH : ANDROID_DATABASE_PATH,
})
const queryClient = new QueryClient({
queryCache: createPersistentQueryCacheForOpSqlite(db),
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 60,
},
},
})