Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/deno/cli/tsc/dts/lib.deno.unstable.d.ts>Deno.Kv#get

A modern runtime for JavaScript and TypeScript.
Latest
method Deno.Kv.prototype.get
import { Deno } from "https://deno.land/x/deno@v1.41.0/cli/tsc/dts/lib.deno.unstable.d.ts";
const { Kv } = Deno;

Retrieve the value and versionstamp for the given key from the database in the form of a Deno.KvEntryMaybe. If no value exists for the key, the returned entry will have a null value and versionstamp.

const db = await Deno.openKv();
const result = await db.get(["foo"]);
result.key; // ["foo"]
result.value; // "bar"
result.versionstamp; // "00000000000000010000"

The consistency option can be used to specify the consistency level for the read operation. The default consistency level is "strong". Some use cases can benefit from using a weaker consistency level. For more information on consistency levels, see the documentation for Deno.KvConsistencyLevel.

Type Parameters

optional
T = unknown

Parameters

key: KvKey
optional
options: { consistency?: KvConsistencyLevel; }