UNPKG

@shadow-dev/orm

Version:

Lightweight dynamic MySQL ORM designed for ShadowCore and modular apps.

29 lines (28 loc) 838 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.initDatabase = initDatabase; exports.getPool = getPool; exports.registerModel = registerModel; exports.getAllModels = getAllModels; // Database.ts const promise_1 = __importDefault(require("mysql2/promise")); let pool; const modelRegistry = new Map(); function initDatabase(config) { pool = promise_1.default.createPool(config); } function getPool() { if (!pool) throw new Error("Database not initialized"); return pool; } // @ts-expect-error wierd generic errors function registerModel(model) { modelRegistry.set(model.name, model); } function getAllModels() { return modelRegistry; }