簡體   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