method Deno.Kv.prototype.get
Kv.prototype.get<T = unknown>(key: KvKey,options?: { consistency?: KvConsistencyLevel; },): Promise<KvEntryMaybe<T>>
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
.
key: KvKey
optional
options: { consistency?: KvConsistencyLevel; }
Promise<KvEntryMaybe<T>>