Shows: populate genre field
This commit is contained in:
parent
d8a3227f57
commit
0758b1ae3d
1 changed files with 13 additions and 5 deletions
|
|
@ -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<any> {
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue