{"id":25840,"library":"koishi-database-memory","title":"Koishi In-Memory Database","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/koishijs/koishi","tags":["javascript","typescript"],"install":[{"cmd":"npm install koishi-database-memory","lang":"bash","label":"npm"},{"cmd":"yarn add koishi-database-memory","lang":"bash","label":"yarn"},{"cmd":"pnpm add koishi-database-memory","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; core Koishi framework required for plugin system and database API","package":"koishi-core","optional":false}],"imports":[{"note":"ESM-only; named export, not default export. TypeScript types are bundled.","wrong":"const MemoryDatabase = require('koishi-database-memory')","symbol":"MemoryDatabase","correct":"import { MemoryDatabase } from 'koishi-database-memory'"},{"note":"CommonJS users cannot use require; use ESM with named import instead. Default export is the same as the named export.","wrong":"import { default as MemoryDatabase } from 'koishi-database-memory'","symbol":"default","correct":"import MemoryDatabase from 'koishi-database-memory'"},{"note":"Use 'import type' for type-only imports to avoid runtime side effects.","wrong":"import { MemoryDatabaseConfig } from 'koishi-database-memory'","symbol":"type MemoryDatabaseConfig","correct":"import type { MemoryDatabaseConfig } from 'koishi-database-memory'"},{"note":"Do not import from dist/; the package exports at the top level.","wrong":"import MemoryDatabase from 'koishi-database-memory/dist/index.js'","symbol":"MemoryDatabase","correct":"import { MemoryDatabase } from 'koishi-database-memory'"}],"quickstart":{"code":"import { Context } from 'koishi-core'\nimport { MemoryDatabase } from 'koishi-database-memory'\n\nconst app = new Context()\napp.plugin(MemoryDatabase, {})\n\n// Now you can use database operations\napp.model.extend('user', {})\napp.model.create('user', { name: 'Alice' }).then(user => {\n  console.log(user)\n})\n\napp.start()","lang":"typescript","description":"Shows how to install and use the MemoryDatabase plugin in a Koishi app, including extending a model and creating a record."},"warnings":[{"fix":"Replace import { MemoryDatabase } from 'koishi-plugin-memory' with import { MemoryDatabase } from 'koishi-database-memory'.","message":"Upgrading from koishi-database-memory v1.0 to v1.2 requires renaming import from 'koishi-plugin-memory' to 'koishi-database-memory'.","severity":"breaking","affected_versions":"<1.2.0"},{"fix":"Use the plugin system: app.plugin(MemoryDatabase, {})","message":"Direct use of `new MemoryDatabase()` is deprecated; use `app.plugin(MemoryDatabase, options)` instead.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use a persistent database like SQLite or MySQL for production. MemoryDatabase is intended for development/testing.","message":"Data is not persisted; all data is lost when the process restarts.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Refer to Koishi database API limitations; use SQL databases for advanced queries.","message":"MemoryDatabase does not support complex queries like joins or aggregations; it implements only basic CRUD operations.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install koishi-database-memory' and ensure it is listed in package.json dependencies.","cause":"Package not installed or misconfigured in dependencies.","error":"Error: Cannot find module 'koishi-database-memory'"},{"fix":"Use `app.plugin(MemoryDatabase, options)` — do not instantiate directly.","cause":"Using `new MemoryDatabase()` instead of `app.plugin(MemoryDatabase)`.","error":"TypeError: MemoryDatabase is not a constructor"},{"fix":"Use ESM import syntax: `import { MemoryDatabase } from 'koishi-database-memory'`.","cause":"MemoryDatabase imported incorrectly (e.g., wrong default import in CommonJS).","error":"Error: [cordis] Invalid plugin: Expected function or object but got..."},{"fix":"Ensure `app.plugin(MemoryDatabase)` is called before any database operations.","cause":"MemoryDatabase plugin not installed before calling model methods.","error":"TypeError: Cannot read properties of undefined (reading 'extend')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}