From db707482451ec7980a9e314c44ff6bcdf7cc069c Mon Sep 17 00:00:00 2001 From: "Aniruddha Adhikary (Ani)" <932949+aniruddha-adhikary@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:34:39 +0800 Subject: [PATCH] fix: pass context to resource methods in log action --- src/log.action.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/log.action.ts b/src/log.action.ts index f259052..af111d5 100644 --- a/src/log.action.ts +++ b/src/log.action.ts @@ -25,7 +25,7 @@ export const rememberInitialRecord: Before = async ( context.initialRecords = [...records]; } else { context.initialRecords = request.query?.recordIds - ? await context.resource.findMany(request.query.recordIds.split(',')) + ? await context.resource.findMany(request.query.recordIds.split(','), context) : []; } @@ -37,7 +37,7 @@ export const rememberInitialRecord: Before = async ( } const id = context.record?.id?.() ?? request.params.recordId; - context.initialRecord = id ? await context.resource.findOne(id) : {}; + context.initialRecord = id ? await context.resource.findOne(id, context) : {}; return request; }; @@ -173,7 +173,7 @@ const createPersistLogAction = } const modifiedRecord = - record ?? (await ModifiedResource.findOne(String(recordId))) ?? null; + record ?? (await ModifiedResource.findOne(String(recordId), context)) ?? null; const newParamsToCompare = ['delete', 'bulkDelete'].includes(action.name) ? ({} as Record) @@ -201,7 +201,7 @@ const createPersistLogAction = ) ), }; - await Log.create(logParams); + await Log.create(logParams, context); } catch (e) { /* The action should not fail nor display a message to the end-user but we must log the error in server's console for developers */