Skip to main content
Module

x/tpy/mod.ts>TpyKV

🔑 A strongly typed Pylon API client.
Go to Latest
class TpyKV
Re-export
import { TpyKV } from "https://deno.land/x/tpy@v1.0.0-pre-release-4/mod.ts";

A KVNamespace interface that (almost) matches the Pylon KVNamespace SDK class.

Constructors

new
TpyKV(
tpyInstance: Tpy,
deploymentID: StringifiedNumber,
kvnamespace: string,
)

Properties

private
deploymentID: StringifiedNumber
private
tpyc: Tpy
readonly
kvnamespace: string

The KV namespace title.

Methods

Clears the namespace. Returning the number of keys deleted.

This operation will delete all the data in the namespace. The data is irrecoverably deleted.

Use with caution!

Returns the number of keys present in this namespace.

delete(key: string, options?: Pylon.KV.OperationOptions.Delete)

Deletes a given key from the namespace. Throwing if the key does not exist, or if Pylon.KV.OperationOptions.Delete | options.prevValue is set the previous value is not equal to the value provided.

get<T extends Pylon.Json = Pylon.Json>(key: string): Promise<T | undefined>

Gets a key's value - returning the value or undefined.

getArrayBuffer(key: string): Promise<ArrayBuffer | undefined>

Gets a key's value - returning the value or undefined.

items<T>(options?: Pylon.KV.OperationOptions.Items): Promise<Pylon.KV.GET.ItemsFlattened<T>>

Exactly like TpyKV.list, except that it returns the key + value pairs instead.

The maximum limit is 100, however.

list(options?: Pylon.KV.OperationOptions.List)

Lists the keys that are set within the namespace.

put(
key: string,
value: Pylon.Json,
options?: Pylon.KV.OperationOptions.Put,
)

Sets the value of a given key within the key-value store.

putArrayBuffer(
key: string,
value: ArrayBuffer,
options?: Pylon.KV.OperationOptions.Put,
)

Sets the value of a given key within the key-value store.