Despite much research and trial and error, I unfortunately do not yet have an elegant solution for the following use case: A user has several posts, which is correctly implemented as a one-to-many relationship. I want to load the user with all his posts, but not all attributes of the posts, only certain ones.
Approach 1: Find
await this.usersRepository.find({relations: ['posts']});
Here I can't define a corresponding select restriction anywhere.
Approach 2: QueryBuilder
await this.usersRepository.createQueryBuilder('user')
.leftJoinAndSelect('user.posts', 'posts').select('posts.title').getMany();
Here I define the restriction supposedly, but the select seems to refer only to user.
Am I missing something? Or is there no intended solution for my use case?
I would be very grateful for help, thanks guys!
TypeORM version 0.2.22