Used TypeORM's sub-relation feature (_profile.title, profile.avatarattachment) to fetch profile avatar and title. Banner can't be fetched yet as it's not present in this branch (and due to the current issues with the branches I can't update it). Noticed this feature wasn't used in other places in the API, such as the profile controller and instead relies on seperate DB requests. I feel like the method I used here is much better, but if it's too inconsistent I could change it.
public async getPostLikesById(id: number): Promise<any> {
if (!id) return null
const repository = await DatabaseConnector.getRepository('PostLike')
return await repository.find({
where: { post: id },
relations: ['post', 'profile', 'profile.avatar_attachment', 'profile.title']
})
}
Used TypeORM's sub-relation feature (_profile.title, profile.avatarattachment) to fetch profile avatar and title. Banner can't be fetched yet as it's not present in this branch (and due to the current issues with the branches I can't update it). Noticed this feature wasn't used in other places in the API, such as the profile controller and instead relies on seperate DB requests. I feel like the method I used here is much better, but if it's too inconsistent I could change it.