Typescript 用数组类型查找

Typescript 用数组类型查找,typescript,typeorm,Typescript,Typeorm,我有一个Mysql数据库,我需要进行一次查询,以返回与ID数组匹配的所有关系(我正在查询关系表),因此我将按正文接收数组,并计划进行下一次查询: const taskRelationFound = await getRepository(TaskRelation).findOne({ where: { ProjectId: ProjectIds , IsActive: true } }); 这是一种异步方法,ProjectSID的值是下一个:[“ccb79423-ed2b-4650-acb4-

我有一个Mysql数据库,我需要进行一次查询,以返回与ID数组匹配的所有关系(我正在查询关系表),因此我将按正文接收数组,并计划进行下一次查询:

const taskRelationFound = await getRepository(TaskRelation).findOne({ where: { ProjectId: ProjectIds , IsActive: true } });
这是一种异步方法,ProjectSID的值是下一个:
[“ccb79423-ed2b-4650-acb4-567c5e2a6cff”,“68ff86e2-1c81-4487-bc7e-dddf1507f99e”]

ProjectId是一个包含所有Id的数组,我要在其中查找每个Id与ProjectId列匹配的关系,但是我在consult中得到一个错误,我不知道为什么

我的实体使用此结构:

   TaskRelationId: string;
    TaskId: string;
    UserId: string;
    ProjectId: string;
    IsResponsable: boolean;
    IsActive: boolean;

那么,如何获得ProjectId与我抛出数组的任何ProjectId匹配的所有关系呢?

当您要将
where
子句应用于数组
ProjectId
时,您需要在
操作符中使用
,如下所示-

import { In } from 'typeorm';
const taskRelationFound = await getRepository(TaskRelation).findOne({ where: { ProjectId: In(ProjectIds) , IsActive: true } });