Skip to content

Commit

Permalink
chore: add missing populations
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin-Frost committed May 6, 2024
1 parent 58ae698 commit 7939baf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/posts/posts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ export class PostsService {
}

findAll() {
return this.postRepository.findAll({ populate: ['author'] });
return this.postRepository.findAll({
populate: ['author', 'likedBy', 'comments'],
});
}

async like(id: number, userId: number) {
const post = await this.postRepository.findOneOrFail(
{ id },
{ populate: ['likedBy'] },
{ populate: ['author', 'likedBy', 'comments'] },
);
const user = await this.userRepository.findOneOrFail({ id: userId });

Expand All @@ -51,7 +53,7 @@ export class PostsService {
async unlike(id: number, userId: number) {
const post = await this.postRepository.findOneOrFail(
{ id },
{ populate: ['likedBy'] },
{ populate: ['author', 'likedBy', 'comments'] },
);
const user = await this.userRepository.findOneOrFail({ id: userId });

Expand Down

0 comments on commit 7939baf

Please sign in to comment.