quicklite
Version:
A lightweight ORM toolkit for SQLite in Node.js applications
112 lines (111 loc) • 2.19 kB
TypeScript
/**
* Information about a database table
*/
export interface TableInfo {
/**
* Table name
*/
name: string;
/**
* Primary key column name (default: 'id')
*/
primaryKey?: string;
/**
* Column definitions
*/
columns: ColumnInfo[];
/**
* Table indices
*/
indices?: IndexInfo[];
}
/**
* Information about a table column
*/
export interface ColumnInfo {
/**
* Column name
*/
name: string;
/**
* Data type (e.g., INTEGER, TEXT, REAL, BLOB)
*/
type: string;
/**
* Whether this column is a primary key
*/
primaryKey?: boolean;
/**
* Whether this column is NOT NULL
*/
notNull?: boolean;
/**
* Whether this column has a UNIQUE constraint
*/
unique?: boolean;
/**
* Default value for this column
*/
default?: any;
/**
* Whether this column auto-increments
*/
autoIncrement?: boolean;
/**
* Foreign key reference (if any)
*/
foreignKey?: ForeignKeyInfo;
}
/**
* Information about a foreign key
*/
export interface ForeignKeyInfo {
/**
* Referenced table name
*/
table: string;
/**
* Referenced column name
*/
column: string;
/**
* ON DELETE action
*/
onDelete?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'SET DEFAULT';
/**
* ON UPDATE action
*/
onUpdate?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'SET DEFAULT';
}
/**
* Information about a table index
*/
export interface IndexInfo {
/**
* Index name
*/
name: string;
/**
* Whether this is a unique index
*/
unique?: boolean;
/**
* Columns included in the index
*/
columns: string[];
}
/**
* Base entity class that all entity models extend
*/
export declare abstract class BaseEntity {
/**
* Returns information about the database table for this entity
* @returns Table information
*/
static getTableInfo(): TableInfo;
/**
* Generates a SQL statement to create the table for this entity
* @returns SQL CREATE TABLE statement
*/
static getCreateTableSQL(): string;
}