Registry / database / koishi-plugin-database-inidb

koishi-plugin-database-inidb

JSON →
library1.2.0jsnpmunverified

koishi-plugin-database-inidb provides a lightweight database service for the Koishi chatbot framework. It stores all data in INI-formatted files, making the database easily inspectable and manually editable outside the application. Currently at stable version 1.2.0, this plugin aims for simplicity and ease of setup by having no external dependencies beyond Koishi itself. Its release cadence is typically event-driven, responding to Koishi framework updates or feature requests. A key differentiator is its file-based approach, which ensures portability and human readability, contrasted with traditional SQL or NoSQL databases. It also features file-locking mechanisms to maintain data consistency during concurrent access, which is crucial for a bot environment. This makes it suitable for smaller Koishi instances where a full-fledged database server is an overkill and resource usage is a primary concern.

npm install koishi-plugin-database-inidb
INSTALL
IMPORT
SIG · KOISHI-PLUGIN-DATA
K
koishi-plugin-database-inidb
databasejavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
import { plugin } from 'koishi-plugin-database-inidb'
const { plugin } = require('koishi-plugin-database-inidb')
Primary export for the Koishi plugin function. Used with `ctx.plugin()`.
Config
import { type Config } from 'koishi-plugin-database-inidb'
import { Config } from 'koishi-plugin-database-inidb'
TypeScript type for the plugin's configuration object. Use `type` for type-only imports.
inidb
import inidb from 'koishi-plugin-database-inidb'
const inidb = require('koishi-plugin-database-inidb').default
While `plugin` is the idiomatic named export, some setups might alias the default export or directly consume it if one exists. Confirm default export behavior.

Demonstrates setting up a Koishi application and integrating `koishi-plugin-database-inidb`. It includes an example of using the database service to store and retrieve user data via simple commands.

import { Context, Schema, h } from 'koishi' import { plugin } from 'koishi-plugin-database-inidb' // Create a basic Koishi instance (replace with your actual setup) const app = new Context({ prefix: ['.'], port: 8080 }); // Apply the INI database plugin app.plugin(plugin, { path: process.env.KOISHI_INI_DB_PATH ?? 'data/inidb' }); // Example usage: register a command that interacts with the database // (assuming database services are set up by the plugin) app.command('set <key:text> <value:text>') .action(async ({ session }, key, value) => { if (!key || !value) return 'Usage: .set <key> <value>'; await session.database.set('user', { id: session.userId }, { [key]: value }); return `Set ${key} for user ${session.userId} to ${value}`; }); app.command('get <key:text>') .action(async ({ session }, key) => { if (!key) return 'Usage: .get <key>'; const user = await session.database.get('user', { id: session.userId }, [key]); if (user && user[key]) { return `Value of ${key} for user ${session.userId} is ${user[key]}`; } else { return `Key ${key} not found for user ${session.userId}`; } }); app.start(); console.log('Koishi app with INI DB started.');
Debug
Known issues
gotchaPerformance may degrade significantly with very large datasets or high concurrent query rates due to the inherent overhead of file I/O operations and locking mechanisms for INI files. This plugin is best suited for small to medium-sized datasets.
fix
For applications requiring high throughput or managing extensive data, consider switching to a more performant database service like `koishi-plugin-database-sqlite` or `koishi-plugin-database-mongo`.
affects: >=1.0.0
breakingManually editing the generated INI database files without proper care can lead to data corruption, schema inconsistencies, or parsing errors, potentially rendering parts or all of your data unusable.
fix
Always back up your database files (`path` directory) before manual modifications. Ensure INI syntax is strictly followed. It is generally recommended to interact with the database only through the Koishi application's API.
affects: >=1.0.0
gotchaThe `path` configuration determines where your database files are stored. Misconfiguring this path (e.g., to a publicly accessible directory or one with insufficient permissions) can expose sensitive bot data or lead to file access errors.
fix
Ensure the configured `path` points to a secure, private directory with appropriate read/write permissions for the user running the Koishi application. Avoid placing database files in public web directories.
affects: >=1.0.0
gotchaThe INI file format is not designed for complex data structures (e.g., nested objects, arrays) or advanced querying capabilities (e.g., JOINs, complex filters). Storing such data might lead to flattened or serialized representations that are less efficient to query.
fix
If your application requires rich data structures or sophisticated query logic, consider using a database plugin that supports SQL (e.g., SQLite, MySQL) or NoSQL (e.g., MongoDB) databases, which are better suited for these scenarios.
affects: >=1.0.0
Errors
Common errors & fixes
EACCES: permission denied, open '...'
The Koishi application process does not have sufficient read/write permissions for the directory configured in `path`.
fix
Ensure the directory specified in the `path` configuration (default: `data/database/inidb`) exists and the user running Koishi has full read/write access to it. You might need to adjust file permissions (`chmod`) or move the directory.
[koishi] plugin load failed: koishi-plugin-database-inidb
This generic error can indicate several issues, including missing peer dependencies (Koishi itself), invalid plugin configuration, or a syntax error within the database INI files.
fix
Verify that `koishi` is installed and meets the peer dependency version (`npm install koishi`). Check the plugin configuration passed to `app.plugin(plugin, config)` for any typos or invalid values. Inspect Koishi's console output for more specific error messages after this generic failure.
INI parsing error: Invalid section or key/value pair in file '...'
One of the INI database files has been corrupted or manually edited in a way that violates the INI file format specification.
fix
Examine the specified INI file for syntax errors (e.g., missing `[section]`, malformed `key=value` pairs). If the data is not critical or backed up, deleting the corrupted file might allow the plugin to regenerate it (though data will be lost for that table).
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
koishirequiredCore framework this plugin extends and relies on.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
koishi-plugin-database-inidb — npm install koishi-plugin-database-inidb · libregistry