StormTrooper
StormTrooper

Reputation: 1573

Typeorm respository find where with select columns

I am trying to implement single query with a where clause and select columns:

Main Query in SQL form:

SELECT name from users WHERE flag = 1;

Now what I have tried so far is:

userRepository.find({
    where: {
        flag: 1
    },
    select: {
        name: true
    }
})

My query works fine if I don't add select option, but with select provided it gives me error.

Any idea what I am doing wrong here?

Upvotes: -1

Views: 53

Answers (1)

Harut Melkonyan
Harut Melkonyan

Reputation: 51

Try to select like this

userRepository.find({
where: {
    flag: 1
},
select: ['name','id']

})

Upvotes: 1

Related Questions