E
E
Evgeny Danilov2021-06-25 11:49:16
SQL
Evgeny Danilov, 2021-06-25 11:49:16

How to get latest record from relationships in TypeORM?

I have implemented a relationship between two tables in the database (these relationships are described in Entity files). But there is a need to get the last record from this connection (it is possible to create a new connection) in a separate field. For example, I have a table of cities and a table of news, between them there is a relationship by city ID (City = one to many, and news - many to one). And when I get the city, I need to immediately get the latest news for this city, but not just taking everything, and then filtering (on the server side already), but immediately get it from the database with the last associated record.

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