Node.js 键入带有顺序和位置的查找选项
我想通过表关系订购这个find函数Node.js 键入带有顺序和位置的查找选项,node.js,sorting,entity,relationship,typeorm,Node.js,Sorting,Entity,Relationship,Typeorm,我想通过表关系订购这个find函数 const [people, total] = await typePersonServiceInstance.find( { take, skip, where: (qb: any) => { qb.where('person.type IN (:...type)', { type }); qb.andWhere('person.status IN (:...status)', { status })
const [people, total] = await typePersonServiceInstance.find(
{
take,
skip,
where: (qb: any) => {
qb.where('person.type IN (:...type)', { type });
qb.andWhere('person.status IN (:...status)', { status });
if (query.search) {
qb.andWhere(new Brackets((subQb) => {
subQb.where('name like :name', { name: `%${query.search}%` });
subQb.orWhere('fantasyName like :fantasyName', { fantasyName: `%${query.search}%` });
subQb.orWhere('person.city like :city', { city: `%${query.search}%` });
subQb.orWhere('person.state like :state', { state: `%${query.search}%` });
subQb.orWhere('person.id = :id', { id: query.search });
}));
}
},
order: {
person: {
status: 'ASC'
}
}
},
);
我面临的问题是,如果我尝试按person
表中的某个属性排序,那么
order: {
anyColumnFromTypePersonHere: 'ASC' | 'DESC'
}
它工作得很好,但如果我想按状态排序(这是person的一个属性),它将不起作用