Skip to content

Commit

Permalink
add: join applications table w/ referrals query
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfredo Flores committed Sep 30, 2024
1 parent 3a72929 commit 47a4768
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/modules/referral/referral.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ type ListReferralsOptions<Selection> = {
};

export async function listReferrals<
Selection extends SelectExpression<DB, 'referrals'>,
Selection extends SelectExpression<DB, 'referrals' | 'applications'>,
>({ select, where }: ListReferralsOptions<Selection>) {
const referrals = await db
.selectFrom('referrals')
.innerJoin('applications', 'applications.referralId', 'referrals.id')
.select(select)
.$if(!!where.referrerId, (qb) => {
return qb.where('referrerId', '=', where.referrerId as string);
Expand Down

0 comments on commit 47a4768

Please sign in to comment.