Registry / database / koishi-database-memory

koishi-database-memory

JSON →
library1.2.0jsnpmunverified

koishi-database-memory is an in-memory database implementation for the Koishi chatbot framework (v4.x). Version 1.2.0 provides a lightweight, zero-configuration database backend that stores all data in memory, suitable for development, testing, or small-scale deployments where persistence is not required. It ships with TypeScript types and requires koishi-core ^1.12.0 as a peer dependency. Unlike SQL-based databases (e.g., koishi-database-sqlite or koishi-database-mysql), it offers the fastest read/write speeds but no data persistence across restarts. The package is maintained as part of the Koishi monorepo and follows its release cadence. It is intended for use cases where temporary storage suffices, and can be easily swapped with a persistent database later.

npm install koishi-database-memory
INSTALL
IMPORT
SIG · KOISHI-DATABASE-ME
K
koishi-database-memory
databasejavascriptv1.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

MemoryDatabase
import { MemoryDatabase } from 'koishi-database-memory'
const MemoryDatabase = require('koishi-database-memory')
ESM-only; named export, not default export. TypeScript types are bundled.
default
import MemoryDatabase from 'koishi-database-memory'
import { default as MemoryDatabase } from 'koishi-database-memory'
CommonJS users cannot use require; use ESM with named import instead. Default export is the same as the named export.
type MemoryDatabaseConfig
import type { MemoryDatabaseConfig } from 'koishi-database-memory'
import { MemoryDatabaseConfig } from 'koishi-database-memory'
Use 'import type' for type-only imports to avoid runtime side effects.
MemoryDatabase
import { MemoryDatabase } from 'koishi-database-memory'
import MemoryDatabase from 'koishi-database-memory/dist/index.js'
Do not import from dist/; the package exports at the top level.

Shows how to install and use the MemoryDatabase plugin in a Koishi app, including extending a model and creating a record.

import { Context } from 'koishi-core' import { MemoryDatabase } from 'koishi-database-memory' const app = new Context() app.plugin(MemoryDatabase, {}) // Now you can use database operations app.model.extend('user', {}) app.model.create('user', { name: 'Alice' }).then(user => { console.log(user) }) app.start()
Debug
Known issues
breakingUpgrading from koishi-database-memory v1.0 to v1.2 requires renaming import from 'koishi-plugin-memory' to 'koishi-database-memory'.
fix
Replace import { MemoryDatabase } from 'koishi-plugin-memory' with import { MemoryDatabase } from 'koishi-database-memory'.
affects: <1.2.0
deprecatedDirect use of `new MemoryDatabase()` is deprecated; use `app.plugin(MemoryDatabase, options)` instead.
fix
Use the plugin system: app.plugin(MemoryDatabase, {})
affects: >=0.0.0
gotchaData is not persisted; all data is lost when the process restarts.
fix
Use a persistent database like SQLite or MySQL for production. MemoryDatabase is intended for development/testing.
affects: >=0.0.0
gotchaMemoryDatabase does not support complex queries like joins or aggregations; it implements only basic CRUD operations.
fix
Refer to Koishi database API limitations; use SQL databases for advanced queries.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'koishi-database-memory'
Package not installed or misconfigured in dependencies.
fix
Run 'npm install koishi-database-memory' and ensure it is listed in package.json dependencies.
TypeError: MemoryDatabase is not a constructor
Using `new MemoryDatabase()` instead of `app.plugin(MemoryDatabase)`.
fix
Use `app.plugin(MemoryDatabase, options)` — do not instantiate directly.
Error: [cordis] Invalid plugin: Expected function or object but got...
MemoryDatabase imported incorrectly (e.g., wrong default import in CommonJS).
fix
Use ESM import syntax: `import { MemoryDatabase } from 'koishi-database-memory'`.
TypeError: Cannot read properties of undefined (reading 'extend')
MemoryDatabase plugin not installed before calling model methods.
fix
Ensure `app.plugin(MemoryDatabase)` is called before any database operations.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
koishi-corerequiredPeer dependency; core Koishi framework required for plugin system and database API
Agent activity
4 hits · last 30 days
node
4
Resources
koishi-database-memory — npm install koishi-database-memory · libregistry