【发布时间】:2021-01-11 12:30:26
【问题描述】:
我想在我的“AuthSubscriber”中使用“Promo”实体存储库。
这样做的原因是我想在创建“用户”实体时自动生成一个“促销”实体并将其分配给“用户”实体。
尝试在订阅者类中初始化存储库时,我收到以下错误:
RepositoryNotFoundError: No repository for "Promo" was found. Looks like this entity is not registered in current "default" connection?
订阅者:
@EventSubscriber()
export class AuthSubscriber implements EntitySubscriberInterface<User> {
promoRepo: Repository<Promo>;
constructor() {
this.promoRepo = getRepository(Promo);
}
listenTo() {
return User;
}
}
Ormconfig:
{
...
"logging": false,
"synchronize": true,
"entities": ["src/entities/**/*.ts"],
"subscribers": ["src/subscribers/**/*.ts"]
}
【问题讨论】:
标签: typeorm