Syntax
relations.add( type1, end1Options, type2[, end2Options[, relationOptions]] )
Description
Creates a relation between types.
Parameters
Parameter | Type | Description |
---|---|---|
type1 | string | Type name. |
end1Options | object | Options for the type1 relation end. See Reference and Collection Options below. |
type2 | string | Related type name. |
end2Options | object | Options for the type2 relation end. See Reference and Collection Options below. |
relationOptions | object | Relation options. See Collection Relation Options below. |
Reference Options
Option | Type | Description |
---|---|---|
reference | string | |
field | string |
Collection Options
Option | Type | Description |
---|---|---|
collection | string | |
field | string |
Collection Relation Options
Option | Type | Description |
---|---|---|
association | string |
Examples
References
Jobs.project:
Jobs.project via a user-defined Jobs.Project_ID field:
Collections
Projects.jobs:
Projects.jobs via a user-defined Jobs.Project_ID field:
One-to-many
Project.jobs <-> Jobs.project:
Project.jobs <-> Jobs.project via a user-defined Jobs.Project_ID field:
One-to-many of the same type
Jobs.children <-> Jobs.parent:
Jobs.children <-> Jobs.parent via a user-defined Jobs.Parent_ID field:
Many-to-many
Projects.jobs <-> Jobs.projects:
Projects.jobs <- Project_Jobs -> Jobs.projects:
Projects.jobs <- Project_Jobs -> Jobs.projects via user-defined fields Project_Jobs.Project_ID and Project_Jobs.Job_ID:
Many-to-many of the same type
Jobs.children:
Jobs.children <-> Jobs.parents:
Many-to-many of the same type, bidirectional
As opposed to Jobs.children above, after adding job1 to job2.related, job1.related also contains job2:
or: