JSPM

cf-workers-idbkv

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 751
  • Score
    100M100P100Q93393F
  • License MIT

IndexedDB (IDB) backed Cloudflare workers KV store for testing.

Package Exports

  • cf-workers-idbkv

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cf-workers-idbkv) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cf-workers-idbkv

Build Status dependencies Status

IndexedDB (IDB) backed Cloudflare workers KV store for testing.

Install

npm install cf-workers-idbkv

Usage

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)

API

See Cloudflare Workers Runtime API docs.

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Alan Shaw