From b6a92325a727ca7827cbfc8d81a4002375961ae7 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Wed, 7 Dec 2022 09:10:04 +0200 Subject: [PATCH] add .exec() to mongo queries --- .../industry-change-application.service.ts | 20 ++++++++++--------- src/resident/resident.service.ts | 6 ++++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/industry-change-application/industry-change-application.service.ts b/src/industry-change-application/industry-change-application.service.ts index 9197291..0dcdcba 100644 --- a/src/industry-change-application/industry-change-application.service.ts +++ b/src/industry-change-application/industry-change-application.service.ts @@ -55,17 +55,19 @@ export class IndustryChangeApplicationService { throw new NotFoundException('Resident not found'); } - return this.applicationModel.find({ - residentSub: options.residentSub, - status: { - $in: options.statuses || Object.values(ApplicationStatus), - }, - objectStatus: ObjectStatus.CURRENT, - }); + return this.applicationModel + .find({ + residentSub: options.residentSub, + status: { + $in: options.statuses || Object.values(ApplicationStatus), + }, + objectStatus: ObjectStatus.CURRENT, + }) + .exec(); } async getById(id: string) { - const find = await this.applicationModel.findById(id); + const find = await this.applicationModel.findById(id).exec(); if (!find) { throw new NotFoundException('The application was not found'); } @@ -151,7 +153,7 @@ export class IndustryChangeApplicationService { } async markDeleted(id: string, token: string) { - const findApplication = await this.applicationModel.findById(id); + const findApplication = await this.applicationModel.findById(id).exec(); if (!findApplication) { throw new NotFoundException('Application was not found'); diff --git a/src/resident/resident.service.ts b/src/resident/resident.service.ts index 96f94bb..06fcde2 100644 --- a/src/resident/resident.service.ts +++ b/src/resident/resident.service.ts @@ -16,10 +16,12 @@ export class ResidentService { } public async getResidentBySub(sub: string): Promise { - return this.residentModel.findOne({ sub }); + return this.residentModel.findOne({ sub }).exec(); } public async save(resident: Partial): Promise { - return this.residentModel.findOneAndUpdate({ sub: resident.sub }, resident); + return this.residentModel + .findOneAndUpdate({ sub: resident.sub }, resident) + .exec(); } }