typeorm#RemoveEvent TypeScript Examples
The following examples show how to use
typeorm#RemoveEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: placement.subscriber.ts From rest-api.ts with MIT License | 5 votes |
async beforeRemove({entity, manager}: RemoveEvent<Placement>) {
const productId = entity.product.id;
const product = await manager.findOneOrFail(Product, {id: productId});
product.quantity += entity.quantity;
await manager.save(product);
}
Example #2
Source File: placement.subscriber.ts From rest-api.ts with MIT License | 5 votes |
async afterRemove({entity, manager}: RemoveEvent<Placement>) {
await this.updateOrderTotal(manager, entity.order);
}
Example #3
Source File: question.subscriber.ts From office-hours with GNU General Public License v3.0 | 5 votes |
async beforeRemove(event: RemoveEvent<QuestionModel>): Promise<void> {
// due to cascades entity is not guaranteed to be loaded
if (event.entity) {
// Send all listening clients an update
await this.queueSSEService.updateQuestions(event.entity.queueId);
}
}