IndexedDB (IDB) backed Cloudflare workers KV store for testing.
npm install cf-workers-idbkv
import { IDBKV } from 'cf-workers-idbkv'
const fruits = new IDBKV('database name')
const key = 'apple:grannysmith'
const value = { name: 'Granny Smith', type: 'apple', color: 'green' }
const metadata = { name: 'Granny Smith' }
await fruits.put(key, JSON.stringify(value), { metadata })
const apple = await fruits.get(key, 'json')
console.log(apple) // { name: 'Granny Smith', type: 'apple', color: 'green' }
const apples = await fruits.list({ prefix: 'apple:' })
console.log(apples) // { keys: [{ name: 'apple:grannysmith', metadata: { name: 'Granny Smith' } }], list_complete: true }
await fruits.delete(key)
See Cloudflare Workers Runtime API docs.
Feel free to dive in! Open an issue or submit PRs.
MIT © Alan Shaw