fix(action-import): import with createdBy & updatedBy field (#4939)

This commit is contained in:
ChengLei Shao 2024-07-24 16:22:07 +08:00 committed by GitHub
parent 027d54dc87
commit 80570c663f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -51,7 +51,9 @@ async function importXlsxAction(ctx: Context, next: Next) {
explain: (ctx.request.body as any).explain,
});
const importedCount = await importer.run();
const importedCount = await importer.run({
context: ctx,
});
ctx.bodyMeta = { successCount: importedCount };
ctx.body = ctx.bodyMeta;

View File

@ -30,6 +30,7 @@ type ImporterOptions = {
type RunOptions = {
transaction?: Transaction;
context?: any;
};
export class XlsxImporter extends EventEmitter {
@ -180,6 +181,7 @@ export class XlsxImporter extends EventEmitter {
await this.options.collection.repository.create({
values: rowValues,
context: options?.context,
transaction,
});