Skip to content

Commit db70748

Browse files
aniruddha-adhikarydziraf
authored andcommitted
fix: pass context to resource methods in log action
1 parent 9b3e040 commit db70748

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/log.action.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const rememberInitialRecord: Before = async (
2525
context.initialRecords = [...records];
2626
} else {
2727
context.initialRecords = request.query?.recordIds
28-
? await context.resource.findMany(request.query.recordIds.split(','))
28+
? await context.resource.findMany(request.query.recordIds.split(','), context)
2929
: [];
3030
}
3131

@@ -37,7 +37,7 @@ export const rememberInitialRecord: Before = async (
3737
}
3838

3939
const id = context.record?.id?.() ?? request.params.recordId;
40-
context.initialRecord = id ? await context.resource.findOne(id) : {};
40+
context.initialRecord = id ? await context.resource.findOne(id, context) : {};
4141

4242
return request;
4343
};
@@ -173,7 +173,7 @@ const createPersistLogAction =
173173
}
174174

175175
const modifiedRecord =
176-
record ?? (await ModifiedResource.findOne(String(recordId))) ?? null;
176+
record ?? (await ModifiedResource.findOne(String(recordId), context)) ?? null;
177177

178178
const newParamsToCompare = ['delete', 'bulkDelete'].includes(action.name)
179179
? ({} as Record<string, any>)
@@ -201,7 +201,7 @@ const createPersistLogAction =
201201
)
202202
),
203203
};
204-
await Log.create(logParams);
204+
await Log.create(logParams, context);
205205
} catch (e) {
206206
/* The action should not fail nor display a message to the end-user
207207
but we must log the error in server's console for developers */

0 commit comments

Comments
 (0)