DB
Class: DB
A singleton class that provides database operations.
Static Methods
getInstance
static getInstance(): DB
Gets the singleton instance of DB.
- Returns: DB instance
Methods
show
show(): Promise<TableList>
Lists all tables in the database.
- Returns:
Promise<TableList>
describe
describe(table: string): Promise<TableDescription>
Gets the description of a table.
- Parameters:
table: Table name
- Returns:
Promise<TableDescription>
select
select(table: string, options?: SelectOptions): Promise<SelectResult>
Selects data from a table.
- Parameters:
table: Table nameoptions: Optional select options
- Returns:
Promise<SelectResult>
Interfaces
TableField
interface TableField {
name: string;
type: string;
nullable: boolean;
default?: string | null;
}
TableDescription
interface TableDescription {
table: string;
fields: TableField[];
}
TableList
interface TableList {
tables: string[];
}
SelectOptions
interface SelectOptions {
fields?: string[];
where?: Record<string, any>;
limit?: number;
offset?: number;
orderBy?: string;
order?: 'asc' | 'desc';
}
SelectResult
interface SelectResult {
total: number;
rows: Record<string, any>[];
}