I have a table in my database called "textDate"
class TextData extends BaseEntity{
id(primaryGeneratedColumn)
ar:string
en:string
}
This entity is used to store all text in my project, such as titles, descriptions, and other fields that have foreign keys to it.
class object extends baseEntity{
id
@OneToOne()
@joinColumn()
title:TextData
...
I need to search through the text data and retrieve records based on certain conditions. I also want to get the objects that have foreign keys to these TextData records. Note: There are several types of objects that have access to the text data - object1 (with title), car (with title), career (with title). All of them have foreign keys to the TextData... Is there anything specific I can do? I've created:
select 'post' as Type,p3.id
from post p3
where p3."tagsId" =any ('{1,2,3}') or p3."titleId" =any ('{1,2,3}')
join text_data td
on td.id = p3."titleId" as title
UNION
select 'career' as Type,c2.id
from career c2
join text_data td
on td.id = c2."titleId" as title
where c2."tagsId" =any ('{1,2,3}')