generate references (#7882)
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
slug: /references/data-model/relationship-methods/belongsto
|
||||
sidebar_label: belongsTo
|
||||
---
|
||||
|
||||
import { TypeList } from "docs-ui"
|
||||
|
||||
# belongsTo Relationship Method - API Reference
|
||||
|
||||
This method defines the inverse of the [hasOne](../dml.Relationship_Methods.hasOne/page.mdx) or [hasMany](../dml.Relationship_Methods.hasMany/page.mdx) relationship.
|
||||
|
||||
For example, a product "belongsTo" a store.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const Product = model.define("product", {
|
||||
id: model.id(),
|
||||
store: model.belongsTo(() => Store, {
|
||||
mappedBy: "products",
|
||||
}),
|
||||
})
|
||||
```
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"T","type":"`object`","description":"The type of the entity builder passed as a first parameter. By default, it's\na function returning the related model.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="belongsTo"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"entityBuilder","type":"T","description":"A function that returns the data model this model is related to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[RelationshipOptions](../../../../types/DmlTypes/types/types.DmlTypes.RelationshipOptions/page.mdx)","description":"The relationship's options.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"mappedBy","type":"`string`","description":"The name of the relationship as defined\nin the other data model. This is only required\nby the `belongsTo` relationship method.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="belongsTo"/>
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
---
|
||||
slug: /references/data-model/relationship-methods/hasmany
|
||||
sidebar_label: hasMany
|
||||
---
|
||||
|
||||
import { TypeList } from "docs-ui"
|
||||
|
||||
# hasMany Relationship Method - API Reference
|
||||
|
||||
This method defines a relationship between two data models,
|
||||
where the owner of the relationship has many records of the related
|
||||
data model, but the related data model only has one owner.
|
||||
|
||||
For example, a store "hasMany" products.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import { model } from "@medusajs/utils"
|
||||
|
||||
const Store = model.define("store", {
|
||||
id: model.id(),
|
||||
products: model.hasMany(() => Product),
|
||||
})
|
||||
```
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"T","type":"`object`","description":"The type of the entity builder passed as a first parameter. By default, it's\na function returning the related model.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="hasMany"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"entityBuilder","type":"T","description":"A function that returns the data model this model is related to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[RelationshipOptions](../../../../types/DmlTypes/types/types.DmlTypes.RelationshipOptions/page.mdx)","description":"The relationship's options.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"mappedBy","type":"`string`","description":"The name of the relationship as defined\nin the other data model. This is only required\nby the `belongsTo` relationship method.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="hasMany"/>
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
---
|
||||
slug: /references/data-model/relationship-methods/hasone
|
||||
sidebar_label: hasOne
|
||||
---
|
||||
|
||||
import { TypeList } from "docs-ui"
|
||||
|
||||
# hasOne Relationship Method - API Reference
|
||||
|
||||
This method defines a relationship between two data models,
|
||||
where the owner of the relationship has one record of the related
|
||||
data model.
|
||||
|
||||
For example: A user "hasOne" email.
|
||||
|
||||
Use the [belongsTo](../dml.Relationship_Methods.belongsTo/page.mdx) method to define the inverse of this relationship in
|
||||
the other data model.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import { model } from "@medusajs/utils"
|
||||
|
||||
const User = model.define("user", {
|
||||
id: model.id(),
|
||||
email: model.hasOne(() => Email),
|
||||
})
|
||||
```
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"T","type":"`object`","description":"The type of the entity builder passed as a first parameter. By default, it's\na function returning the related model.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="hasOne"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"entityBuilder","type":"T","description":"A function that returns the data model this model is related to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[RelationshipOptions](../../../../types/DmlTypes/types/types.DmlTypes.RelationshipOptions/page.mdx)","description":"The relationship's options.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"mappedBy","type":"`string`","description":"The name of the relationship as defined\nin the other data model. This is only required\nby the `belongsTo` relationship method.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="hasOne"/>
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
slug: /references/data-model/relationship-methods/manytomany
|
||||
sidebar_label: manyToMany
|
||||
---
|
||||
|
||||
import { TypeList } from "docs-ui"
|
||||
|
||||
# manyToMany Relationship Method - API Reference
|
||||
|
||||
This method defines a relationship between two data models,
|
||||
where both data models have many related records.
|
||||
|
||||
For example, an order is associated with many products, and a product
|
||||
is associated with many orders.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import { model } from "@medusajs/utils"
|
||||
|
||||
const Order = model.define("order", {
|
||||
id: model.id(),
|
||||
products: model.manyToMany(() => Product),
|
||||
})
|
||||
|
||||
const Product = model.define("product", {
|
||||
id: model.id(),
|
||||
order: model.manyToMany(() => Order),
|
||||
})
|
||||
```
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"T","type":"`object`","description":"The type of the entity builder passed as a first parameter. By default, it's\na function returning the related model.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="manyToMany"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"entityBuilder","type":"T","description":"A function that returns the data model this model is related to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[ManyToManyOptions](../../../entity_builder/types/dml.entity_builder.ManyToManyOptions/page.mdx)","description":"The relationship's options.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"mappedBy","type":"`string`","description":"The name of the relationship as defined\nin the other data model. This is only required\nby the `belongsTo` relationship method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"pivotTable","type":"`string`","description":"The name of the pivot table\ncreated in the database for this relationship.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"pivotEntity","type":"() => [DmlEntity](../../../entity/classes/dml.entity.DmlEntity/page.mdx)<any>","description":"A function that returns the data model \nrepresenting the pivot table created in the\ndatabase for this relationship.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="manyToMany"/>
|
||||
Reference in New Issue
Block a user