UNPKG

@adonisjs/lucid

Version:

SQL ORM built on top of Active Record pattern

55 lines (54 loc) 1.51 kB
import { EventEmitter } from 'node:events'; import { type Application } from '@adonisjs/core/app'; import type { Database } from '../../database/main.ts'; import type { OrmSchemaGeneratorConfig, DatabaseColumn } from '../../types/schema_generator.ts'; /** * OrmSchemaGenerator orchestrates the process of generating TypeScript * model schemas from database tables. */ export declare class OrmSchemaGenerator extends EventEmitter<{ /** * Emitted when tables are collected from the database */ 'collect:tables': [tables: string[]]; /** * Emitted for each table with its column information */ 'table:info': [info: { tableName: string; columns: Record<string, DatabaseColumn>; }]; /** * Emitted when schema generation starts */ 'generating:schema': []; }> { private db; private application; private config; /** * Schema builder instance */ private builder; /** * Query client instance */ private connection; constructor(db: Database, application: Application<any>, config: OrmSchemaGeneratorConfig); /** * Load schema rules from the configured paths */ private loadSchemaRules; /** * Fetch all tables and their columns from the database */ private fetchTablesAndColumns; /** * Generate schemas and write to output file */ generate(): Promise<void>; /** * Close database connections */ close(): Promise<void>; }