Skip to content

Commit

Permalink
fix: pass context to resource methods in log action
Browse files Browse the repository at this point in the history
  • Loading branch information
aniruddha-adhikary authored and dziraf committed Oct 16, 2024
1 parent 9b3e040 commit db70748
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/log.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
: [];
}

Expand All @@ -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;
};
Expand Down Expand Up @@ -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<string, any>)
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit db70748

Please sign in to comment.