Emit item crud

This commit is contained in:
rijkvanzanten
2020-09-10 13:47:02 -04:00
parent 5e8ce8f358
commit a046af7a5c

View File

@@ -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;
}