@bunnykit/orm 0.1.10 → 0.1.11
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 +19 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -394,6 +394,25 @@ await Schema.create("posts", (table) => {
|
|
|
394
394
|
});
|
|
395
395
|
```
|
|
396
396
|
|
|
397
|
+
The foreign key call adds the constraint only. Define the local column first, and make its type match the referenced column:
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
await Schema.create("users", (table) => {
|
|
401
|
+
table.uuid("id").primary();
|
|
402
|
+
table.string("email").unique();
|
|
403
|
+
table.timestamps();
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
await Schema.create("posts", (table) => {
|
|
407
|
+
table.increments("id");
|
|
408
|
+
table.uuid("user_id");
|
|
409
|
+
table.foreign("user_id").references("id").on("users").onDelete("cascade");
|
|
410
|
+
table.string("title");
|
|
411
|
+
table.text("content");
|
|
412
|
+
table.timestamps();
|
|
413
|
+
});
|
|
414
|
+
```
|
|
415
|
+
|
|
397
416
|
---
|
|
398
417
|
|
|
399
418
|
## Query Builder
|
package/package.json
CHANGED