A
A
AE422020-06-02 20:07:39
PostgreSQL
AE42, 2020-06-02 20:07:39

How to extract data from typeorm index array?

Example for everyone

I have an array with user IDs
[1, 2, 3, 4] in my table.
Is it possible to extract information for each using typeorm?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Khodzitsky, 2020-06-09
@AE42

Can. Documentation.
If these are just IDs without any connection, you can use In :

import {In} from "typeorm";

const users = await connection.getRepository(User).find({
    ids: In([1, 2, 3, 4])
})

If the users are related to another entity, relations: ["users"] can be specified .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question