Recently, I got stuck scratching my head, because of how TypeORM behaves, given entities:
class Event extends BaseEntity {
location: Address
}
class Address {
@Column({ type: 'varchar' })
city: string
}
Now if I want to select the event’s city, apparently I can do it in two ways, which is confusing:
jobEventRepo.createQueryBuilder('jobEvent').select('location.city')
// or
jobEventRepo.createQueryBuilder('jobEvent').select('city')
Both work the same, the first one was what I was using for long, but the second – shorthand way for doing the same I just discovered accidentally. Why do both work, is there a documentation for that, is one of those preferred?