瀏覽代碼

return the async function

Sven Czarnian 2 年之前
父節點
當前提交
71589fe1b4
共有 1 個文件被更改,包括 2 次插入6 次删除
  1. 2 6
      src/airport/airport.service.ts

+ 2 - 6
src/airport/airport.service.ts

@@ -32,19 +32,17 @@ export class AirportService {
   }
 
   async registerAirport(airport: Airport): Promise<boolean> {
-    this.airportExists(airport.icao).then(async (exists) => {
+    return this.airportExists(airport.icao).then(async (exists) => {
       if (!exists) {
         await this.airportModel.create(airport);
       }
 
       return !exists;
     });
-
-    return false;
   }
 
   async updateAirport(airport: Airport): Promise<boolean> {
-    this.airportExists(airport.icao).then(async (exists) => {
+    return this.airportExists(airport.icao).then(async (exists) => {
       if (exists) {
         await this.airportModel.findOneAndUpdate(
           { icao: airport.icao },
@@ -54,8 +52,6 @@ export class AirportService {
 
       return exists;
     });
-
-    return false;
   }
 
   async deleteAirport(icao: string): Promise<void> {