diff --git a/src/shows/shows.service.ts b/src/shows/shows.service.ts index 4e7a475..393382e 100644 --- a/src/shows/shows.service.ts +++ b/src/shows/shows.service.ts @@ -17,9 +17,13 @@ export class ShowsService { let shows; if (showsPerPage !== undefined) { const skip = (page - 1) * showsPerPage; - shows = await this.showModel.find().skip(skip).limit(showsPerPage); + shows = await this.showModel + .find() + .skip(skip) + .limit(showsPerPage) + .populate('genres'); } else { - shows = await this.showModel.find(); + shows = await this.showModel.find().populate('genres'); } const total = await this.showModel.countDocuments(); return { @@ -29,7 +33,7 @@ export class ShowsService { } async findId(id: string): Promise { - return this.showModel.findById(id); + return this.showModel.findById(id).populate('genres'); } async search(name: string, page: number, showsPerPage: number) { @@ -41,9 +45,13 @@ export class ShowsService { if (showsPerPage !== undefined) { const skip = (page - 1) * showsPerPage; - shows = await this.showModel.find(filter).skip(skip).limit(showsPerPage); + shows = await this.showModel + .find(filter) + .skip(skip) + .limit(showsPerPage) + .populate('genres'); } else { - shows = await this.showModel.find(filter); + shows = await this.showModel.find(filter).populate('genres'); } return { shows: shows,