K
Kysely•15mo ago
Coffee11

How to convert this raw query to kysely?

UPDATE finance_reimbursement_approval_matrix
SET has_approved = true
WHERE approval_matrix_id = 'c78f11f0-7014-47cf-82b7-838a43b34b20'
AND reimbursement_request_id IN (
SELECT reimbursement_request_id
FROM finance_reimbursement_requests
WHERE reimbursement_request_id = 'e1dafc7e-a54f-4888-95f1-8cb57f22dfba'
AND request_status_id = '33bfa3b3-1dfa-471f-a7bb-80a9a8842fc5'
);
UPDATE finance_reimbursement_approval_matrix
SET has_approved = true
WHERE approval_matrix_id = 'c78f11f0-7014-47cf-82b7-838a43b34b20'
AND reimbursement_request_id IN (
SELECT reimbursement_request_id
FROM finance_reimbursement_requests
WHERE reimbursement_request_id = 'e1dafc7e-a54f-4888-95f1-8cb57f22dfba'
AND request_status_id = '33bfa3b3-1dfa-471f-a7bb-80a9a8842fc5'
);
as of now, this is what I have done.
await trx
.updateTable('finance_reimbursement_approval_matrix')
.set({
has_approved: true,
performed_by_user_id: user.original_user_id,
updated_at: new Date(),
})
.where((eb) =>
eb
.selectFrom('finance_reimbursement_requests')
.innerJoin(
'finance_reimbursement_approval_matrix',
'finance_reimbursement_approval_matrix.reimbursement_request_id',
'finance_reimbursement_requests.reimbursement_request_id',
)
.where(
'finance_reimbursement_approval_matrix.approval_matrix_id',
'=',
approval_matrix_id,
)
.where(
'finance_reimbursement_requests.request_status_id',
'=',
PENDING_REQUEST)
await trx
.updateTable('finance_reimbursement_approval_matrix')
.set({
has_approved: true,
performed_by_user_id: user.original_user_id,
updated_at: new Date(),
})
.where((eb) =>
eb
.selectFrom('finance_reimbursement_requests')
.innerJoin(
'finance_reimbursement_approval_matrix',
'finance_reimbursement_approval_matrix.reimbursement_request_id',
'finance_reimbursement_requests.reimbursement_request_id',
)
.where(
'finance_reimbursement_approval_matrix.approval_matrix_id',
'=',
approval_matrix_id,
)
.where(
'finance_reimbursement_requests.request_status_id',
'=',
PENDING_REQUEST)
3 Replies
Coffee11
Coffee11OP•15mo ago
Appreciate you man thank you kyse.link @koskimas is that a playground for kysely?
Igal
Igal•15mo ago
yeah! 😄
Want results from more Discord servers?
Add your server