Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to do a full join with Typeorm?

Tags:

typeorm

Is there a way to do a full join with Typeorm?

My current query looks like this:

this.myRepository.createQueryBuilder('myEntity')

I need to fetch all myEntity rows. Sometimes they are related to a myRelatedEntity row, in which case the data of the latter must be fetched too. Sometimes they are not related to a myRelationEntity, in which case I still need to fetch the myEntity row.

Apparently there is no other way to do what I need than with a FULL JOIN. However it seems like FULL JOINs are not available in Typeorm.

Is there any way I can reach my goal?

like image 777
papillon Avatar asked Sep 17 '25 12:09

papillon


1 Answers

In my case I used query for that.

this.myRepository.query(`
    SELECT *
    FROM myEntity
    FULL JOIN otherEntity ON otherEntity.id = myEntity.fid
`);
like image 175
zennkaiii Avatar answered Sep 20 '25 07:09

zennkaiii