{"id":16635,"library":"kirito.db.remote","title":"KiritoDB Remote Database","description":"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.","status":"active","version":"1.0.36","language":"javascript","source_language":"en","source_url":"https://github.com/KiritoTeam/kirito.db.remote","tags":["javascript","database","br","pt-br","brazilian","only-portuguese","portuguese","no-english","quick.db"],"install":[{"cmd":"npm install kirito.db.remote","lang":"bash","label":"npm"},{"cmd":"yarn add kirito.db.remote","lang":"bash","label":"yarn"},{"cmd":"pnpm add kirito.db.remote","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"KiritoDB is the main class exported by the library, used for all database interactions. The official documentation exclusively uses CommonJS `require` syntax for importing.","symbol":"KiritoDB","correct":"const { KiritoDB } = require(\"kirito.db.remote\")"}],"quickstart":{"code":"const { KiritoDB } = require(\"kirito.db.remote\");\n\nasync function run() {\n  const secretKey = process.env.KIRITO_DB_SECRET_KEY ?? '';\n  if (!secretKey) {\n    console.error(\"Environment variable KIRITO_DB_SECRET_KEY is required for authentication.\");\n    process.exit(1);\n  }\n\n  const db = new KiritoDB(secretKey);\n  console.log(\"KiritoDB initialized successfully.\");\n\n  // Set a user's name\n  await db.set(\"users.1234.name\", \"João\");\n  console.log(\"Set users.1234.name to João.\");\n\n  // Retrieve the user's name\n  const userName = await db.get(\"users.1234.name\");\n  console.log(`Retrieved users.1234.name: ${userName}`);\n\n  // Add points to a user's score\n  await db.add(\"users.1234.score\", 50);\n  console.log(\"Added 50 points to users.1234.score.\");\n  let userScore = await db.get(\"users.1234.score\");\n  console.log(`Current users.1234.score: ${userScore}`);\n\n  // Subtract points\n  await db.sub(\"users.1234.score\", 15);\n  console.log(\"Subtracted 15 points from users.1234.score.\");\n  userScore = await db.get(\"users.1234.score\");\n  console.log(`Current users.1234.score: ${userScore}`);\n\n  // Retrieve all data from the database\n  const allData = await db.all();\n  console.log(\"All data currently in database:\\n\", JSON.stringify(allData, null, 2));\n\n  // Delete a specific key\n  await db.delete(\"users.1234.name\");\n  console.log(\"Deleted users.1234.name.\");\n  const deletedUserName = await db.get(\"users.1234.name\");\n  console.log(`users.1234.name after deletion: ${deletedUserName}`); // Should be null/undefined\n}\n\nrun().catch(console.error);","lang":"javascript","description":"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."},"warnings":[{"fix":"Before using `add` or `sub`, ensure that the target key's value is, and remains, a number. Initialize numeric keys with a default number (e.g., 0) if they might not exist to prevent type errors.","message":"The `add` and `sub` methods are strictly designed for numeric values. Attempting to use them on keys where the stored value is a non-numeric data type (such as strings, objects, or arrays) will result in a runtime error and the operation will fail.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always prepend `await` when invoking `db.get('key')` or `db.all()` within an `async` function to ensure the operation completes and returns the expected data.","message":"The `get` and `all` methods return Promises, indicating asynchronous operations. It is crucial to use the `await` keyword with these calls to correctly retrieve the resolved data. Failing to `await` will result in working with a pending Promise object instead of the actual value from the database.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Obtain a valid secret API key from the KiritoDB service and pass it as the first argument to `new KiritoDB('your_secret_key')`. Ensure this key is kept secure and not exposed publicly.","message":"A secret API key is a mandatory requirement for initializing `KiritoDB`. The library will not function correctly, and database operations will fail, if a valid key is not provided to the `KiritoDB` constructor.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"For maximum compatibility and reliability, prefer setting primitive types (strings, numbers, booleans) directly. If complex data structures like arrays or objects must be stored, consider serializing them into JSON strings (e.g., `JSON.stringify(value)`) before storing and deserializing upon retrieval (e.g., `JSON.parse(retrievedValue)`).","message":"The documentation for the `set` method contains contradictory information regarding its support for complex data types. While one statement claims it 'accepts any type of value' (string, number), a direct warning immediately follows, stating 'If the value is an array or object, it will cause an error.' Developers should proceed with caution and assume that directly setting arrays or objects might lead to issues.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure you provide your secret key as a non-empty string when initializing: `new KiritoDB('your_secret_key')`. Validate the key's correctness.","cause":"The `KiritoDB` constructor was called without providing a valid secret API key, or the provided key was empty/invalid.","error":"Error: Sua chave secreta está faltando ou é inválida."},{"fix":"Always use `await` before calls to `db.get()` and `db.all()` to ensure the Promise resolves and returns the actual data before further processing.","cause":"Attempting to access a property on an `undefined` value, commonly occurring when `await` is omitted for an asynchronous operation like `db.get()` or `db.all()`, causing the code to operate on a pending Promise instead of the resolved data.","error":"TypeError: Cannot read properties of undefined (reading 'someProperty')"},{"fix":"Confirm that the target key exclusively stores numeric values before using `db.add()` or `db.sub()`. Consider initializing keys with a numeric default if they might be empty, or validating the type before performing arithmetic operations.","cause":"The `add` or `sub` method was invoked on a key (`users.1234.score` in this example) whose currently stored value is not a number, such as a string, object, or array.","error":"Error: O valor atual da chave 'users.1234.score' não é um número."}],"ecosystem":"npm"}