Shofiqul Alam
Shofiqul Alam

Reputation: 615

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']
                
                
            }

    );

how to add where clause here so that i can find records only where user id is one or 7 or 13.

Upvotes: 3

Views: 5003

Answers (1)

Art Olshansky
Art Olshansky

Reputation: 3356

You've missed round brackets and probably missed importing the In operator:

import { In } from 'typeorm';

...
...
...

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

Upvotes: 6

Related Questions