繁体   English   中英

TypeORM查找where子句,如何在多个参数中添加where

[英]TypeORM find where clause, how to add where in multiple parameter

this.sampleRepo.find (
            {
                where: {
                    id: In ["1","7","13"]

                  }
                order: {
                    id: "DESC"
                },
                select: ['id','group']
                
                
            }

    );

如何在此处添加 where 子句,以便我只能找到用户 ID 为 1 或 7 或 13 的记录。

您错过了圆括号,并且可能错过了导入In运算符:

import { In } from 'typeorm';

...
...
...

this.sampleRepo.find({
    where: {
      id: In(['1', '7', '13'])
    },
    order: {
      id: 'DESC'
    },
    select: ['id', 'group']
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM