generate references (#7882)

This commit is contained in:
Shahed Nasser
2024-07-01 16:02:36 +03:00
committed by GitHub
parent b9036eca1a
commit dd864da4e0
2424 changed files with 106679 additions and 116201 deletions
@@ -0,0 +1,30 @@
---
slug: /references/data-model/define
---
import { TypeList } from "docs-ui"
# define Method - API Reference
This method defines a data model.
## Example
```ts
import { model } from "@medusajs/utils"
const MyCustom = model.define("my_custom", {
id: model.id(),
name: model.text(),
})
export default MyCustom
```
## Type Parameters
<TypeList types={[{"name":"Schema","type":"[DMLSchema](../../../../../types/DmlTypes/types/types.DmlTypes.DMLSchema/page.mdx)","description":"The type of the accepted schema in the second parameter of the method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"$dataType","type":"T","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"$dataType","type":"T","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[RelationshipTypes](../../../../../types/DmlTypes/types/types.DmlTypes.RelationshipTypes/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="define"/>
## Parameters
<TypeList types={[{"name":"nameOrConfig","type":"[DefineOptions](../../../types/dml.entity_builder.DefineOptions/page.mdx)","description":"Either the data model's name, or configurations to name the data model.\nThe data model's name must be unique.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"tableName","type":"`string`","description":"The name of the data model's table in the database.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The data model's name.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"schema","type":"Schema","description":"The schema of the data model's properties.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="define"/>
@@ -0,0 +1,25 @@
import { TypeList } from "docs-ui"
# EntityBuilder
Entity builder exposes the API to create an entity and define its
schema using the shorthand methods.
## Methods
- [define](../../EntityBuilder/methods/dml.entity_builder.EntityBuilder.define/page.mdx)
- [id](../../../Property_Types/methods/dml.Property_Types.id/page.mdx)
- [text](../../../Property_Types/methods/dml.Property_Types.text/page.mdx)
- [boolean](../../../Property_Types/methods/dml.Property_Types.boolean/page.mdx)
- [number](../../../Property_Types/methods/dml.Property_Types.number/page.mdx)
- [bigNumber](../../../Property_Types/methods/dml.Property_Types.bigNumber/page.mdx)
- [array](../../../Property_Types/methods/dml.Property_Types.array/page.mdx)
- [dateTime](../../../Property_Types/methods/dml.Property_Types.dateTime/page.mdx)
- [json](../../../Property_Types/methods/dml.Property_Types.json/page.mdx)
- [enum](../../../Property_Types/methods/dml.Property_Types.enum/page.mdx)
- [hasOne](../../../Relationship_Methods/methods/dml.Relationship_Methods.hasOne/page.mdx)
- [belongsTo](../../../Relationship_Methods/methods/dml.Relationship_Methods.belongsTo/page.mdx)
- [hasMany](../../../Relationship_Methods/methods/dml.Relationship_Methods.hasMany/page.mdx)
- [manyToMany](../../../Relationship_Methods/methods/dml.Relationship_Methods.manyToMany/page.mdx)
## constructor
@@ -0,0 +1,19 @@
import { TypeList } from "docs-ui"
# DefineOptions
**DefineOptions**: `string` \| `object`
## name
`Optional` **name**: `string`
The data model's name.
___
## tableName
**tableName**: `string`
The name of the data model's table in the database.
@@ -0,0 +1,34 @@
import { TypeList } from "docs-ui"
# ManyToManyOptions
**ManyToManyOptions**: [RelationshipOptions](../../../../types/DmlTypes/types/types.DmlTypes.RelationshipOptions/page.mdx) & `object` \| `object`
## mappedBy
`Optional` **mappedBy**: `string`
The name of the relationship as defined
in the other data model. This is only required
by the `belongsTo` relationship method.
___
## pivotTable
`Optional` **pivotTable**: `string`
The name of the pivot table
created in the database for this relationship.
___
## pivotEntity
`Optional` **pivotEntity**: () => [DmlEntity](../../../entity/classes/dml.entity.DmlEntity/page.mdx)&#60;any&#62;
A function that returns the data model
representing the pivot table created in the
database for this relationship.
### Type declaration
@@ -0,0 +1,5 @@
import { TypeList } from "docs-ui"
# model
`Const` **model**: [EntityBuilder](../../classes/dml.entity_builder.EntityBuilder/page.mdx)