0.1.16 • Published 8 months ago
@linkbcms/database v0.1.16
@linkbcms/database
Database module for the LinkB CMS, providing database schema generation and management functionality.
Features
- Database adapters for PostgreSQL (and future support for other databases)
- Schema generation from CMS configuration
- Migration management
- Database utilities for connecting and interacting with the database
Installation
npm install @linkbcms/databaseUsage
Basic usage
import { execute } from '@linkbcms/database';
// Execute a database action
await execute('gen-schema', {
databaseType: 'postgres',
connectionString: 'postgresql://user:password@localhost:5432/mydb',
schemaDir: './database/schema',
migrationDir: './database/migrations',
configPath: './cms.config.tsx'
});Available actions
gen-schema: Generate database schema based on CMS configurationmigrate: Run pending migrationstest-connection: Test database connectivityreset: Reset database by dropping all tables
API Reference
execute(action, options)
Execute a database action with the specified options.
Parameters:
action: The action to execute (string)options: Configuration options object:workspaceRoot: Root directory of the workspacedatabaseType: Type of database to connect toconnectionString: Database connection stringschema: Database schema nameschemaDir: Directory for schema filesmigrationDir: Directory for migration filesconfigPath: Path to the CMS configuration fileloadConfigFn: Function to load the CMS configuration
License
MIT