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

Sho*_*lam 3 mysql node.js typeorm

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

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

    );
Run Code Online (Sandbox Code Playgroud)

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

Art*_*sky 6

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

import { In } from 'typeorm';

...
...
...

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