@3lineas/d1-orm 1.0.11 → 1.0.13
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.
- package/README.md +24 -4
- package/dist/cli/index.cjs +596 -94
- package/dist/cli/index.js +596 -94
- package/dist/index.cjs +171 -1
- package/dist/index.d.cts +75 -2
- package/dist/index.d.ts +75 -2
- package/dist/index.js +170 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,16 +86,36 @@ This command is non-interactive and automatically detects your project structure
|
|
|
86
86
|
|
|
87
87
|
### Available Commands
|
|
88
88
|
|
|
89
|
-
####
|
|
89
|
+
#### Manage Models & Schema
|
|
90
|
+
|
|
91
|
+
The ORM provides interactive tools to manage your database schema and models.
|
|
90
92
|
|
|
91
93
|
```bash
|
|
92
|
-
# Create a model
|
|
94
|
+
# Create a new model interactively
|
|
95
|
+
# It will prompt you for attributes and relationships
|
|
93
96
|
pnpm orm make:model User
|
|
94
97
|
|
|
95
|
-
#
|
|
96
|
-
pnpm orm
|
|
98
|
+
# Add more attributes or relations to an existing model
|
|
99
|
+
pnpm orm model:add
|
|
97
100
|
```
|
|
98
101
|
|
|
102
|
+
**Supported attribute types:**
|
|
103
|
+
|
|
104
|
+
- `string`, `text`: For text data.
|
|
105
|
+
- `integer`, `float`: For numeric data.
|
|
106
|
+
- `boolean`: For true/false values.
|
|
107
|
+
- `json`: Stored as text, parsed automatically.
|
|
108
|
+
- `enum`: Includes database-level `CHECK` constraints.
|
|
109
|
+
- `date`, `datetime`: For temporal data.
|
|
110
|
+
- `blob`: For binary data.
|
|
111
|
+
- `relation`: Interactive menu for `HasOne`, `HasMany`, and `BelongsTo`.
|
|
112
|
+
|
|
113
|
+
**Relationship Automation:**
|
|
114
|
+
When you define a relationship through the CLI:
|
|
115
|
+
|
|
116
|
+
1. The **Model** file is updated with the correct method (e.g., `posts() { return this.hasMany(Post); }`).
|
|
117
|
+
2. The **Migration** file automatically includes the foreign key column if you choose `BelongsTo`.
|
|
118
|
+
|
|
99
119
|
#### Run Migrations
|
|
100
120
|
|
|
101
121
|
```bash
|