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