Skip to main content
Home
This release is 3 versions behind 0.30.0 — the latest version of @kitsonk/kv-toolbox. Jump to latest

Built and signed on GitHub Actions

Utilities for working with Deno KV. Encrypted values, batching atomic transactions, handling blobs, querying/filtering, and more.

This package works with Node.js, Deno, Bun, Browsers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
4 weeks ago (0.29.0)

Provides the function batchedAtomic which is like Deno.Kv.prototype.atomic but will work around the per atomic transaction limits imposed by Deno KV.

It also supports setBlob() and checkBlob() to allow setting of checking of kv-toolbox blob values as part of a transaction.

In the past, Deno KV had very low limits (like 10 mutations per transaction) but those limits have been changed to far more reasonable levels, so in most cases batchedAtomic is not needed. The only advantage is that you can make arbitrarily large atomic transactions and not worry about having to deal with a limit failure in code. But most users should consider just dealing with Deno.Kv.prototype.atomic directly.

Examples

Example 1

import { batchedAtomic } from "@kitsonk/kv-toolbox/batched_atomic";

const kv = await Deno.openKv();
await batchedAtomic(kv)
  .check({ key: ["hello"], versionstamp: null })
  .set(["hello"], "deno kv")
  .commit();
await kv.close();

Classes

c
BatchedAtomicOperation

The class that encapsulates the batched atomic operations. Works around limitations imposed by Deno KV related to individual atomic operations.

Functions

f
batchedAtomic

Similar to Deno.Kv.prototype.atomic but deals with the limits of transactions imposed by Deno KV.

Interfaces

I
BatchAtomicOptions

Options which can be adjusted when using a batched atomic.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@kitsonk/kv-toolbox

Import symbol

import * as mod from "@kitsonk/kv-toolbox/batched_atomic";
or

Import directly with a jsr specifier

import * as mod from "jsr:@kitsonk/kv-toolbox/batched_atomic";

Add Package

pnpm i jsr:@kitsonk/kv-toolbox
or (using pnpm 10.8 or older)
pnpm dlx jsr add @kitsonk/kv-toolbox

Import symbol

import * as mod from "@kitsonk/kv-toolbox/batched_atomic";

Add Package

yarn add jsr:@kitsonk/kv-toolbox
or (using Yarn 4.8 or older)
yarn dlx jsr add @kitsonk/kv-toolbox

Import symbol

import * as mod from "@kitsonk/kv-toolbox/batched_atomic";

Add Package

vlt install jsr:@kitsonk/kv-toolbox

Import symbol

import * as mod from "@kitsonk/kv-toolbox/batched_atomic";

Add Package

npx jsr add @kitsonk/kv-toolbox

Import symbol

import * as mod from "@kitsonk/kv-toolbox/batched_atomic";

Add Package

bunx jsr add @kitsonk/kv-toolbox

Import symbol

import * as mod from "@kitsonk/kv-toolbox/batched_atomic";