KiritoDB Remote Database

1.0.36 · active · verified Wed Apr 22

KiritoDB Remote is a simple, key-value remote database designed for Node.js environments, including bots and APIs. It allows developers to store and retrieve data using dot-notation paths, similar to object property access (e.g., `"users.1234.points"`). As of version 1.0.36, it provides a straightforward API for common database operations such as `get`, `set`, `add`, `sub`, and `delete`. A key characteristic of this library is that all its documentation and examples are provided exclusively in Portuguese, catering specifically to the Brazilian Portuguese-speaking developer community. While explicit release cadence information is not available, its consistent versioning suggests ongoing maintenance. Its primary differentiator is its focus on simplicity and accessibility for Portuguese-speaking developers, offering a remote storage solution without the overhead of more complex database systems.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing KiritoDB, setting and getting data for various keys, performing numeric addition and subtraction, retrieving all stored data, and deleting specific keys. Requires setting `KIRITO_DB_SECRET_KEY` environment variable.

const { KiritoDB } = require("kirito.db.remote");

async function run() {
  const secretKey = process.env.KIRITO_DB_SECRET_KEY ?? '';
  if (!secretKey) {
    console.error("Environment variable KIRITO_DB_SECRET_KEY is required for authentication.");
    process.exit(1);
  }

  const db = new KiritoDB(secretKey);
  console.log("KiritoDB initialized successfully.");

  // Set a user's name
  await db.set("users.1234.name", "João");
  console.log("Set users.1234.name to João.");

  // Retrieve the user's name
  const userName = await db.get("users.1234.name");
  console.log(`Retrieved users.1234.name: ${userName}`);

  // Add points to a user's score
  await db.add("users.1234.score", 50);
  console.log("Added 50 points to users.1234.score.");
  let userScore = await db.get("users.1234.score");
  console.log(`Current users.1234.score: ${userScore}`);

  // Subtract points
  await db.sub("users.1234.score", 15);
  console.log("Subtracted 15 points from users.1234.score.");
  userScore = await db.get("users.1234.score");
  console.log(`Current users.1234.score: ${userScore}`);

  // Retrieve all data from the database
  const allData = await db.all();
  console.log("All data currently in database:\n", JSON.stringify(allData, null, 2));

  // Delete a specific key
  await db.delete("users.1234.name");
  console.log("Deleted users.1234.name.");
  const deletedUserName = await db.get("users.1234.name");
  console.log(`users.1234.name after deletion: ${deletedUserName}`); // Should be null/undefined
}

run().catch(console.error);

view raw JSON →