Koishi DataView Plugin

2.7.8 · active · verified Wed Apr 22

koishi-plugin-dataview is a plugin for the Koishi chatbot framework, providing a web-based console interface to view and interact with various database tables directly within the Koishi Console. It leverages Koishi's existing database connectivity to present data in a structured, browsable format, enhancing debugging and administrative capabilities. The current stable version is 2.7.8. Koishi plugins generally follow the release cadence of the Koishi core framework, with frequent updates to ensure compatibility and introduce new features. Its key differentiator is its seamless integration into the Koishi Console, offering a unified management experience for bot operations and underlying data, which is crucial for complex bot applications needing direct data inspection without external tools, simplifying bot administration and data inspection.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up a minimal Koishi application, load the Koishi Console, and then integrate the DataView plugin to inspect database tables via the web interface. It uses an in-memory database for quick demonstration.

import { App, Schema } from 'koishi';
import { Console } from '@koishijs/plugin-console';
import DataViewPlugin from 'koishi-plugin-dataview';

const config = {
  port: 8080,
  host: 'localhost',
  logLevel: 'info',
  database: {
    // Use 'memory' for a quick demo. For production, configure a real database
    // like 'mysql', 'sqlite', or 'mongo' to see persistent data.
    protocol: 'memory'
  }
};

const app = new App(config);

// Koishi Console plugin is a peer dependency and must be loaded.
app.plugin(Console);

// Load the DataView plugin without specific options for default behavior.
app.plugin(DataViewPlugin, {
  // Optional: configure specific tables to display or other plugin settings.
  // Example: maxRows: 100, // Limit number of rows per table displayed
});

app.start().then(() => {
  console.log('Koishi application started successfully.');
  console.log('Access the Koishi Console at http://localhost:8080/console');
  console.log('DataView will be available under the "Data" tab in the console.');
}).catch(err => {
  console.error('Failed to start Koishi application:', err);
});

view raw JSON →