Follow dicedb.io (or) just use this docker command:
docker run -p 7379:7379 dicedb/dicedb:v1.0.7bun add dicedb-sdknpm install dicedb-sdkimport { NewClient } from "dicedb-sdk";
const { response: client, error } = await NewClient("localhost", 7379-);
if (error) {
console.error("Failed to connect:", error);
} else {
console.log("Client connected successfully!");
}// Using `Fire` with a wire.command:
import { wire } from "dicedb-sdk";
const { response, error } = await client.Fire(wire.command({
cmd: "SET",
args: ["key", "value"],
}));
if (error) {
console.error("Error executing command:", error);
} else {
console.log("Response Status:", response?.status);
}
// Using `FireString` with a command string:
const { response: getResponse, error: getError } = await client.FireString("GET key");
if (getError) {
console.error("Error executing command:", getError);
} else {
console.log("Response Value:", getResponse?.response.value);
}Use the WatchChGetter method to receive an async iterator for watching changes.
const { response: iterator, error: watchInitError } = await client.WatchChGetter();
if (watchInitError) {
console.error("Error setting up watch:", watchInitError);
} else {
for await (const item of iterator) {
console.log("Watched item:", item.response.value);
}
}Refer to example.ts for a complete example of how to use the client library.
