-
-
Notifications
You must be signed in to change notification settings - Fork 206
Closed
Labels
Type: Feature RequestRequest to add a new feature to the packageRequest to add a new feature to the package
Description
Why this feature is required (specific use-cases will be appreciated)?
As it is very helpful to have hasOne and hasMany relationships,
it is needed to have hasOneThrough relationship, to define a has one relationship via an intermediate model.
This knowing the available support of hasManyThrough relationship, that help to define a has many relationship via an intermediate model.
Have you tried any other work arounds?
I didn't found an appropriate work around for adonis, but i'm open for reference or helpful ressource.
That said i'm actually using a computed property with instructions to get the targeting related model instance.
@computed()
public async referrer() {
const referral = await Referral.findBy('user_id', this.id)
return User.find(referral.referrerId)
}Less meaningful than
@hasOneThrough([() => User, () => Referral], {
foreignKey: 'user_id',
throughLocalKey: 'referrer_id',
throughForeignKey: 'id',
})
public referrer: HasOneThrough<typeof User>Are you willing to work on it with little guidance?
Yes
Metadata
Metadata
Assignees
Labels
Type: Feature RequestRequest to add a new feature to the packageRequest to add a new feature to the package