首页 > 解决方案 > 传递 typeorm 实体作为参数来调用静态方法

问题描述

如何将 typeorm 实体作为参数传递给方法并在实体内执行静态方法?

我试图做这样的事情:

export const doSmthWithEntity = async <T extends BaseEntity>(entity: T, name: string, description: string = '') => {
  const element = await entity.findOne({id: 1});
}

doSmthWithEntity(Customer, '','')

但它不起作用。有任何想法吗?

标签: typescripttypeorm

解决方案


推荐阅读