Lightweight dynamic MySQL ORM designed for ShadowCore and modular apps.
npm install @shadow-dev/ormbash
npm install @shadow-dev/orm mysql2
`
---
🛠 Usage Example
`ts
import { Model, Repository, initDatabase, registerModel } from "@shadow-dev/orm";
const Ticket = new Model<{
id: string;
type: "support" | "report";
data: { message: string };
createdAt: Date;
}>("tickets", {
id: "string",
type: "string",
data: "json",
createdAt: "datetime"
});
initDatabase({
host: "localhost",
user: "root",
password: "password",
database: "mydb"
});
registerModel(Ticket);
// Auto-create table on startup
await syncSchema();
const tickets = new Repository(Ticket);
// Use it
await tickets.create({
id: "ticket-001",
type: "support",
data: { message: "Help me!" },
createdAt: new Date()
});
`
---
🧠 Schema Types
ShadowORM supports:
| Type | SQL Equivalent |
|---------------------------|-------------------|
| string | VARCHAR(255) |
| number | INT |
| boolean | BOOLEAN |
| json | LONGTEXT |
| datetime | DATETIME |
| FOREIGN_KEY: