objection.js icon indicating copy to clipboard operation
objection.js copied to clipboard

HasMany through relation Feature Request

Open kaushal-aubie opened this issue 3 years ago • 1 comments

Does objection has HasManyRelation through relation, I wanted something like this

users: {
        relation: Model.HasManyRelation,   // hasManyThorugh needed
        modelClass: User,
        join: {
          from: 'marksheets.id',
          through: {
            modelClass: MarksheetMember,
            from: 'marksheetMembers.marksheetid',
            to: 'marksheetMembers.userId',
          },
          to: 'users.id',
        },
      },

Otherwise, i have to

await db.Marksheet.query().findById(marksheetId).withGraphFetched('users.user') // if it is not through relation

kaushal-aubie avatar Jun 24 '22 08:06 kaushal-aubie

HasManyThrough is a ManyToMany Relation, you could just use ManyToMany

abedmurrar avatar Jul 16 '22 13:07 abedmurrar