I
I
IIITRIX2022-03-23 11:26:08
ORM
IIITRIX, 2022-03-23 11:26:08

How to form createQueryBuilder in typeorm?

There was such a query in typeorm 0.2 version

const topic = await Topic.query(`
  select
  t.*,
  f.user_id user_followed_id,
  m.user_id user_moderator_id
  from topic t
  left join follow f on f.topic_id = t.id and f.user_id = $1
  left join moderator m on m.topic_id = t.id and m.user_id = $2
  where t.title = $3`;


In version 0.3.2, everything has changed and now they do it according to the documentation
const topic = await AppDataSource
    .getRepository(Topic)
    .createQueryBuilder("topic")
    .getOne()


I can not understand. Please help me with my example.
To understand how to make requests in the future

Thank you all in advance

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question