docs: document composite indices + primary key changes (#7902)

This commit is contained in:
Shahed Nasser
2024-07-02 12:34:44 +03:00
committed by GitHub
parent a84e5a6ced
commit 6cb28eedf7
13 changed files with 205 additions and 93 deletions
@@ -31,12 +31,12 @@ export const oneToOneHighlights = [
import { model } from "@medusajs/utils"
const User = model.define("user", {
id: model.id(),
id: model.id().primaryKey(),
email: model.hasOne(() => Email),
})
const Email = model.define("email", {
id: model.id(),
id: model.id().primaryKey(),
user: model.belongsTo(() => User, {
mappedBy: "email",
}),
@@ -70,12 +70,12 @@ export const oneToManyHighlights = [
import { model } from "@medusajs/utils"
const Store = model.define("store", {
id: model.id(),
id: model.id().primaryKey(),
products: model.hasMany(() => Product),
})
const Product = model.define("product", {
id: model.id(),
id: model.id().primaryKey(),
store: model.belongsTo(() => Store, {
mappedBy: "products",
}),
@@ -101,12 +101,12 @@ export const manyToManyHighlights = [
import { model } from "@medusajs/utils"
const Order = model.define("order", {
id: model.id(),
id: model.id().primaryKey(),
products: model.manyToMany(() => Product),
})
const Product = model.define("product", {
id: model.id(),
id: model.id().primaryKey(),
order: model.manyToMany(() => Order),
})
```
@@ -132,14 +132,14 @@ export const relationNameHighlights = [
import { model } from "@medusajs/utils"
const User = model.define("user", {
id: model.id(),
id: model.id().primaryKey(),
email: model.hasOne(() => Email, {
mappedBy: "owner",
}),
})
const Email = model.define("email", {
id: model.id(),
id: model.id().primaryKey(),
owner: model.belongsTo(() => User, {
mappedBy: "email",
}),
@@ -170,7 +170,7 @@ export const highlights = [
import { model } from "@medusajs/utils"
const Store = model.define("store", {
id: model.id(),
id: model.id().primaryKey(),
products: model.hasMany(() => Product),
})
.cascades({
@@ -178,7 +178,7 @@ const Store = model.define("store", {
})
const Product = model.define("product", {
id: model.id(),
id: model.id().primaryKey(),
store: model.belongsTo(() => Store, {
mappedBy: "products",
}),