From a046af7a5cd6351e26151c8af06b2e657be01d4a Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Thu, 10 Sep 2020 13:47:02 -0400 Subject: [PATCH] Emit item crud --- api/src/services/items.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/api/src/services/items.ts b/api/src/services/items.ts index c716eca737..ce716e5edd 100644 --- a/api/src/services/items.ts +++ b/api/src/services/items.ts @@ -14,6 +14,7 @@ import { } from '../types'; import Knex from 'knex'; import cache from '../cache'; +import emitter from '../emitter'; import PayloadService from './payload'; import AuthorizationService from './authorization'; @@ -150,6 +151,13 @@ export default class ItemsService implements AbstractService { await cache.clear(); } + emitter.emitAsync(`item.create.${this.collection}`, { + collection: this.collection, + item: primaryKeys, + action: 'create', + payload: payloads, + }); + return primaryKeys; }); @@ -311,6 +319,13 @@ export default class ItemsService implements AbstractService { await cache.clear(); } + emitter.emitAsync(`item.update.${this.collection}`, { + collection: this.collection, + item: key, + action: 'update', + payload, + }); + return key; } @@ -373,6 +388,12 @@ export default class ItemsService implements AbstractService { await cache.clear(); } + emitter.emitAsync(`item.delete.${this.collection}`, { + collection: this.collection, + item: key, + action: 'delete', + }); + return key; }