Function: resourcefulHasManyThrough()
ts
function resourcefulHasManyThrough<RelatedModel>(
model: [() => RelatedModel, () => LucidModel],
options: Partial<HasManyThroughRelationOptions<RelatedModel>> &
Partial<ResourcefulRelationshipDefinition<LucidModel>>,
): (target: any, propertyKey: string) => void;Decorator to define a resourceful hasManyThrough relationship on a Lucid model property.
Type Parameters
| Type Parameter |
|---|
RelatedModel extends LucidModel |
Parameters
| Parameter | Type | Description |
|---|---|---|
model | [() => RelatedModel, () => LucidModel] | Tuple of functions returning the related model and through model classes. |
options | Partial<HasManyThroughRelationOptions<RelatedModel>> & Partial<ResourcefulRelationshipDefinition<LucidModel>> | HasManyThrough 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 { resourcefulHasManyThrough } from "@nhtio/lucid-resourceful";
class User {
@resourcefulHasManyThrough([() => Role, () => UserRolePivot], {
foreignKey: "user_id",
})
public roles: HasManyThrough<typeof Role>;
}