Function: ManyToMany()
ManyToMany(
target,options):PropertyDecorator
Defined in: src/decorators/ManyToMany.ts:21
Property decorator establishing a many-to-many relationship joined via a junction table.
Parameters
| Parameter | Type | Description |
|---|---|---|
target | () => Function | Lambda returning the target related entity constructor. |
options | ManyToManyOptions | Junction table name (through), primary foreign key, and other foreign key. |
Returns
PropertyDecorator
Usecase
Model many-to-many associations (e.g. Students and Courses via StudentCourses junction table).
Example
@ManyToMany(() => Tag, { through: 'post_tags', foreignKey: 'postId', otherKey: 'tagId' })
tags!: Tag[];