Function: resourcefulManyToMany()
ts
function resourcefulManyToMany<RelatedModel>(
model: () => RelatedModel,
options: Partial<ManyToManyRelationOptions<ManyToMany<RelatedModel>>> &
Partial<ResourcefulRelationshipDefinition<LucidModel>>,
): (target: any, propertyKey: string) => void;Decorator to define a resourceful manyToMany relationship on a Lucid model property.
Type Parameters
| Type Parameter |
|---|
RelatedModel extends LucidModel |
Parameters
| Parameter | Type | Description |
|---|---|---|
model | () => RelatedModel | Function returning the related model class. |
options | Partial<ManyToManyRelationOptions<ManyToMany<RelatedModel>>> & Partial<ResourcefulRelationshipDefinition<LucidModel>> | ManyToMany relationship options and resourceful relationship definition. |
Returns
Property decorator function.
ts
(target: any, propertyKey: string): void;Parameters
| Parameter | Type |
|---|---|
target | any |
propertyKey | string |
Returns
void
Example
ts
import { resourcefulManyToMany } from "@nhtio/lucid-resourceful";
class User {
@resourcefulManyToMany(() => Role, { pivotTable: "role_user" })
public roles: ManyToMany<typeof Role>;
}