postgresql - TypeORM:订阅两个模型
问题描述
嗨,我一直在使用 TypeORM,但在订阅两个模型时遇到问题,动作......我想听听两个模型的变化,而不仅仅是一个
我有 2 个模型用户和帖子我如何收听这两个模型的更新
import { EntitySubscriberInterface, EventSubscriber, InsertEvent, UpdateEvent } from 'typeorm';
import { User } from '../users/user.entity';
@EventSubscriber()
export class HistorySubscriber implements EntitySubscriberInterface<User> {
listenTo() {
return User; // here i would like to listen also to post Updates
}
/**
* Called after User update.
*/
async afterUpdate(event: UpdateEvent<User>) {
const newValue = event.entity;
}
}
解决方案
推荐阅读
- ruby-on-rails - Action Mailer 和 Sidekiq,电子邮件卡在队列中
- nginx - 用于编译动态模块的 nginx-v1.20.1 ./configure 问题
- java - ArrayList.clear 抛出 ArrayIndexOutOfBoundsException
- javascript - 在模板文字字符串中使用 if 运算符
- c# - 实体框架中的第一步,是否有与休眠的链接?
- html - 如何正确设置垂直滚动捕捉 css
- postgresql - GreenPlum SQL 语句迁移到 HiveSQL
- powershell - Powershell解析日期时间
- identityserver4 - 将 Zendesk 链接到 Identityserver4
- python - 如果我有两个图像掩码作为 numpy 数组,我如何将它们叠加在一起。考虑重叠和非重叠区域