@shadow-dev/orm 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ export interface BaseSchema {
3
3
  data?: any;
4
4
  createdAt?: Date;
5
5
  }
6
- export type SimpleFieldType = "string" | "int" | "float" | "boolean" | "json" | "datetime";
6
+ export type SimpleFieldType = "string" | "text" | "mediumtext" | "longtext" | "int" | "bigint" | "float" | "double" | "decimal" | "boolean" | "date" | "time" | "datetime" | "timestamp" | "json" | "binary" | "varbinary" | "uuid";
7
7
  export interface FieldOptions {
8
8
  type: SimpleFieldType;
9
9
  pk?: boolean;
@@ -6,14 +6,35 @@ import { getAllModels, getPool } from "../core/Database.js";
6
6
  /* Helpers */
7
7
  /* ---------------------------------- */
8
8
  function mapType(type) {
9
- switch (type) {
9
+ switch (type.toLowerCase()) {
10
+ // strings
10
11
  case "string": return "VARCHAR(255)";
11
- case "json": return "JSON";
12
- case "datetime": return "DATETIME";
12
+ case "text": return "TEXT";
13
+ case "mediumtext": return "MEDIUMTEXT";
14
+ case "longtext": return "LONGTEXT";
15
+ // numbers
13
16
  case "int": return "INT";
17
+ case "bigint": return "BIGINT";
14
18
  case "float": return "FLOAT";
19
+ case "double": return "DOUBLE";
20
+ case "decimal": return "DECIMAL(10,2)";
21
+ // boolean
15
22
  case "boolean": return "BOOLEAN";
16
- default: return type;
23
+ // dates
24
+ case "date": return "DATE";
25
+ case "time": return "TIME";
26
+ case "datetime": return "DATETIME";
27
+ case "timestamp": return "TIMESTAMP";
28
+ // json
29
+ case "json": return "JSON";
30
+ // binary
31
+ case "binary": return "BINARY(16)";
32
+ case "varbinary": return "VARBINARY(255)";
33
+ // uuid (convention)
34
+ case "uuid": return "CHAR(36)";
35
+ // passthrough (escape hatch)
36
+ default:
37
+ return type; // allows raw MySQL like "ENUM(...)", "VARCHAR(64)", etc.
17
38
  }
18
39
  }
19
40
  function formatDefault(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shadow-dev/orm",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Lightweight dynamic MySQL ORM designed for ShadowCore and modular apps.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",