Skip to main content

getMany

method Deno.Kv.prototype.getMany
Jump to headingKv.prototype.getMany<T extends readonly unknown[]>(
keys: readonly [...[K in keyof T]: KvKey],
options?: { consistency?: KvConsistencyLevel; },
): Promise<[K in keyof T]: KvEntryMaybe<T[K]>>

Retrieve multiple values and versionstamps from the database in the form of an array of Deno.KvEntryMaybe objects. The returned array will have the same length as the keys array, and the entries will be in the same order as the keys. If no value exists for a given key, the returned entry will have a null value and versionstamp.

const db = await Deno.openKv();
const result = await db.getMany([["foo"], ["baz"]]);
result[0].key; // ["foo"]
result[0].value; // "bar"
result[0].versionstamp; // "00000000000000010000"
result[1].key; // ["baz"]
result[1].value; // null
result[1].versionstamp; // null

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 Jump to heading

Jump to headingT extends readonly unknown[]

Parameters Jump to heading

Jump to headingkeys: readonly [...[K in keyof T]: KvKey]
optional
Jump to headingoptions: { consistency?: KvConsistencyLevel; }

Return Type Jump to heading

Promise<[K in keyof T]: KvEntryMaybe<T[K]>>
Back to top