I came across a rather peculiar database schema that includes a jsonb field with userId and userType attributes, along with two different user tables for distinct user types. The selection of the table to join based on the userType is crucial.
Although I can utilize a query builder to construct the necessary SQL queries, my system involves dynamically transforming GQL into Mikro filters, making manual assembly quite complex.
Is there a feasible method to achieve something akin to
@Entity()
class Job {
@Property({ type: 'jsonb' })
props: unknown
@Formula(alias => `select user.name, user.dob, user.etc from user where user.id = ${alias.props->>userId`)
user: User
}
or a similar approach? Essentially, using decorators to specify how to fetch specific data components.