Pass current knex trx instance to hook resolver functions

Closes #4558
This commit is contained in:
rijkvanzanten
2021-03-17 22:07:58 -04:00
parent ac223d2137
commit 2a71f0c0dd
3 changed files with 9 additions and 0 deletions

View File

@@ -59,6 +59,7 @@ export class AuthenticationService {
accountability: this.accountability,
status: 'pending',
user: user?.id,
database: this.knex,
});
const emitStatus = (status: 'fail' | 'success') => {
@@ -70,6 +71,7 @@ export class AuthenticationService {
accountability: this.accountability,
status,
user: user?.id,
database: this.knex,
});
};

View File

@@ -67,6 +67,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
action: 'create',
payload: payloads[i],
schema: this.schema,
database: this.knex,
});
if (customProcessed && customProcessed.length > 0) {
@@ -177,6 +178,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
action: 'create',
payload: payloads,
schema: this.schema,
database: this.knex,
});
return Array.isArray(data) ? savedPrimaryKeys : savedPrimaryKeys[0];
@@ -282,6 +284,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
action: 'update',
payload,
schema: this.schema,
database: this.knex,
});
if (customProcessed && customProcessed.length > 0) {
@@ -382,6 +385,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
action: 'update',
payload,
schema: this.schema,
database: this.knex,
});
return key;
@@ -486,6 +490,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
action: 'delete',
payload: null,
schema: this.schema,
database: this.knex,
});
await this.knex.transaction(async (trx) => {
@@ -519,6 +524,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
action: 'delete',
payload: null,
schema: this.schema,
database: this.knex,
});
return key;