UNPKG

@shadow-dev/orm

Version:

Lightweight dynamic MySQL ORM designed for ShadowCore and modular apps.

25 lines (24 loc) 794 B
export interface BaseSchema { id?: string; data?: any; createdAt?: Date; } export interface ForeignKeyDefinition { column: string; reference: string; } export type SimpleFieldType = "string" | "int" | "float" | "boolean" | "json" | "datetime"; export interface FieldOptions { type: SimpleFieldType; pk?: boolean; required?: boolean; default?: any; } export type SchemaValue = SimpleFieldType | FieldOptions; export type FlexibleSchema<T> = Record<keyof T, SchemaValue>; export declare class Model<T extends Partial<BaseSchema> = BaseSchema> { readonly name: string; readonly schema: FlexibleSchema<T>; readonly foreignKeys: ForeignKeyDefinition[]; constructor(name: string, schema: FlexibleSchema<T>, foreignKeys?: ForeignKeyDefinition[]); }