emit create event take out transaction scope.

This commit is contained in:
Mehmet Tüken
2021-01-11 09:18:43 +03:00
parent d9dc466f9a
commit ce21ce54ee

View File

@@ -159,21 +159,21 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
await cache.clear();
}
emitter
.emitAsync(`${this.eventScope}.create`, {
event: `${this.eventScope}.create`,
accountability: this.accountability,
collection: this.collection,
item: primaryKeys,
action: 'create',
payload: payloads,
schema: this.schema,
})
.catch((err) => logger.warn(err));
return primaryKeys;
});
emitter
.emitAsync(`${this.eventScope}.create`, {
event: `${this.eventScope}.create`,
accountability: this.accountability,
collection: this.collection,
item: savedPrimaryKeys,
action: 'create',
payload: payloads,
schema: this.schema,
})
.catch((err) => logger.warn(err));
return Array.isArray(data) ? savedPrimaryKeys : savedPrimaryKeys[0];
}
@@ -381,7 +381,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
const payloads = toArray(data);
for (const single of payloads as Partial<Item>[]) {
let payload = clone(single);
const payload = clone(single);
const key = payload[primaryKeyField];
if (!key) {