【发布时间】:2021-03-02 19:42:22
【问题描述】:
我有下一个代码:
const CompaniesRelation: Array<CompanyRelation> = await getRepository(CompanyRelation).find({ where:{ UserId: data.UserId, IsActive: true} });
它应该返回一个包含如下对象的数组:
[{CompanyId"a"},{CompanyId"b"},{CompanyId"c"}]
我的下一步是:
const ids: Array<string> = CompaniesRelation.map(c => c.CompanyId);
我需要在 TypeOrm 选择中使用它,在这里我需要选择一个表的所有内容,其中数组等于 COmpany 和 CompaniesRelation 之间的 ID
const CompanyData: Array<Company> = await getRepository(Company).find({ where:{ CompanyId: data.UserId IN(´${JSON.stringify(ids).slice(1, -1)}´) } });
所以它的语法是错误的,但我不知道为什么,它的正确语法如何以及如何获得我正在尝试的数组?
【问题讨论】:
标签: typescript typeorm