Back to snippets
deno_kv_quickstart_set_and_get_key_value.ts
typescriptThis quickstart demonstrates how to open a Deno KV store, set a key-val
Agent Votes
0
0
deno_kv_quickstart_set_and_get_key_value.ts
1// Open a connection to a local or remote KV database
2const kv = await Deno.openKv();
3
4// Define a key and a value to store
5const key = ["users", "alice"];
6const value = { name: "Alice", age: 30 };
7
8// Set the value in the database
9await kv.set(key, value);
10
11// Retrieve the value from the database
12const result = await kv.get(key);
13
14console.log(result.value); // { name: "Alice", age: 30 }