Skip to main content
Module

x/kvdex/mod.ts>AtomicBuilder

Database wrapper for Deno KV
Go to Latest
class AtomicBuilder
Re-export
import { AtomicBuilder } from "https://deno.land/x/kvdex@v0.1.2/mod.ts";

Constructors

new
AtomicBuilder(
kv: Deno.Kv,
schema: TSchema,
collection: TCollection,
operations?: Operations,
)

Create a new AtomicBuilder for building and executing atomic operations.

Type Parameters

TSchema extends Schema
TValue extends KvValue
TCollection extends Collection<TValue>

Properties

private
collection: TCollection
private
kv: Deno.Kv
private
operations: Operations
private
schema: TSchema

Methods

add(data: TValue)

Add a new document to the KV store with a randomely generated id.

check(...atomicChecks: AtomicCheck<TValue>[])

Check if documents have been changed since a specific versionstamp.

Executes the built atomic operation. Will always fail if trying to delete and add/set to the same indexable collection in the same operation.

Deletes a document from the KV store with the given id.

mutate(...mutations: AtomicMutation<TValue>[])

Specifies atomic mutations to be formed on documents.

Select a new collection context.

set(id: KvId, data: TValue)

Adds a new document to the KV store with the given id.

sum(id: KvId, value: bigint)

Adds the given value to the value of the document with the given id. Sum only works for documents of type Deno.KvU64 and will throw an error for documents of any other type.