TypeORM find where clause, how to add where in multiple parameter

Viewed 3125
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.

1 Answers

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']
});
Related