A lightweight JSON file-based database service plugin for Koishi chatbot framework. Current stable version is 1.2.0. It stores data in JSON files under `data/database/jsondb/` directory, with no external database dependencies, making it ideal for small bots and quick prototyping. Released as part of the Service More collection, it provides standard Koishi database operations (CRUD) with simple configuration. Compared to SQL-based alternatives, it sacrifices scalability for zero setup overhead. Ships TypeScript type definitions. Peer dependency on Koishi ^4.17.1.
npm install koishi-plugin-database-jsondbVerified import paths — ran on the pinned version, not inferred.
Complete setup: install plugin, register it, declare table types, extend model, and use database operations (get, create, set) in a middleware.
Use only in single-process environments. For clustering, consider a proper database like SQLite or MySQL.
Always specify `primary` option in `ctx.model.extend(table, fields, { primary: 'field' })`.Stay updated with Koishi changelogs. Currently `export const inject = ['database']` is correct.
Migrate files manually from old directory to new one before upgrading.
Run `npm install koishi-plugin-database-jsondb` and ensure import is `import DatabaseJsondb from 'koishi-plugin-database-jsondb'`.
Add `export const inject = ['database']` to your plugin module and ensure `app.plugin(databaseJsondb)` is called before your plugin.
Add `primary: 'fieldName'` option in `ctx.model.extend('table', fields, { primary: 'fieldName' })`.Ensure the application has write permissions to the data directory. Create the directory manually if needed: `mkdir -p data/database/jsondb`.