Package Exports
- jsonjsdb-builder
Readme
Jsonjsdb Builder
A development tool for converting relational database tables into jsonjs format compatible with jsonjsdb.
Currently supports Excel (.xlsx) files as source, where each file represents one database table.
Installation
npm install jsonjsdb-builderTable of Contents
Basic Usage
Simple Database Update
Convert Excel files to jsonjs format:
import JsonjsdbBuilder from 'jsonjsdb-builder'
const builder = new JsonjsdbBuilder()
await builder.setOutputDb('app_db') // Output directory
await builder.updateDb('db') // Source Excel files directoryParameters:
app_db: Target directory for generated jsonjs filesdb: Source directory containing .xlsx files
Vite Integration
Development Workflow
Integrate with Vite for automatic database updates during development:
import { defineConfig } from 'vite'
import FullReload from 'vite-plugin-full-reload'
import { JsonjsdbWatcher, jsonjsdbAddConfig } from 'jsonjsdb-builder'
// Setup database watcher
await JsonjsdbWatcher.setDb('app_db')
await JsonjsdbWatcher.watch('db')
await JsonjsdbWatcher.updatePreview('preview', 'data')
export default defineConfig({
plugins: [
jsonjsdbAddConfig('data/jsonjsdb_config.html'),
process.env.NODE_ENV && FullReload(JsonjsdbWatcher.getTableIndexFilePath()),
],
})Features:
- Auto-reload: Automatically updates jsonjs files when Excel sources change
- Config injection: Adds jsonjsdb configuration to your HTML
- Hot reload: Triggers browser refresh on database changes