miniorm
Version:
A lightweight, minimal TypeScript ORM & query‑builder for MySQL, PostgreSQL and SQLite
48 lines (47 loc) • 1.43 kB
TypeScript
type ColumnType = 'varchar' | 'integer' | 'boolean' | 'enum' | 'timestamp';
interface ColumnOption {
type: ColumnType;
length?: number;
notNull?: string;
autoIncrement?: string;
default?: string | number | boolean | null;
primary?: string;
unique?: string;
enum?: string[] | number[];
}
export declare class FluentTableBuilder {
sql: string;
queryies: {
[db: string]: string[];
};
columns: Record<string, ColumnOption>;
private column;
private engineType;
private charsetType;
private dbName;
private dbType;
private tableName;
constructor(tableName: string, dbName: string);
set(opt?: {
db?: string;
table?: string;
}): this;
engine(engine: 'InnoDB' | 'MyISAM' | 'MEMORY' | 'CSV' | 'ARCHIVE'): this;
charset(charset: string): this;
id(nameOrLength?: string | number, length?: number): this;
string(name: string, length: number): this;
integer(name: string, length: number): this;
bool(name: string): this;
enum(name: string, values: any[]): this;
timestamps(): this;
primary(): this;
unique(): this;
notNULL(): this;
nullable(): this;
private auto_increment;
default(value: any): this;
toSQL(): string;
build(): Promise<void>;
static checkTableExists(db: any, dbType: 'mysql' | 'postgresql' | 'sqlite', tableName: string): Promise<boolean>;
}
export {};