export const myUnion =
() => (eb: ExpressionBuilder<KyselyDB, keyof KyselyDB>) => {
return eb
.selectFrom('profile')
.innerJoin('account', 'account.id', 'profile.account_id')
.select((eb) => [
eb.fn.coalesce('account.name', sql.lit('')).as('name'),
eb
.ref('profile.ids', '->>')
.key('value')
.as('code'),
'user_id',
]);
.union((eb) =>
eb.parens(
eb.selectFrom('invitees').select(['name', 'code', 'user_id']),
),
);
};
const x = await kysely
.selectFrom(myUnion())
.select(['name', 'code'])
.execute()
export const myUnion =
() => (eb: ExpressionBuilder<KyselyDB, keyof KyselyDB>) => {
return eb
.selectFrom('profile')
.innerJoin('account', 'account.id', 'profile.account_id')
.select((eb) => [
eb.fn.coalesce('account.name', sql.lit('')).as('name'),
eb
.ref('profile.ids', '->>')
.key('value')
.as('code'),
'user_id',
]);
.union((eb) =>
eb.parens(
eb.selectFrom('invitees').select(['name', 'code', 'user_id']),
),
);
};
const x = await kysely
.selectFrom(myUnion())
.select(['name', 'code'])
.execute()