db-04-flights/src/services/airport.service.ts
Jonas Hinterdorfer d905f7c8ae implemented task 4
2025-03-16 13:33:07 +01:00

24 lines
775 B
TypeScript

import {ServiceBase} from "./serviceBase";
import {AirportModel} from "../models/airport.model";
export class AirportService extends ServiceBase {
static async getOne(icao : string) : Promise<AirportModel | null>{
const sql = `select icao, name, country, runwayLength from Airport where icao = ?1;`
const params = {
1: icao
}
return await this.get<AirportModel>(sql, params);
}
static async getAll() : Promise<AirportModel[]>{
const sql = `select icao, name, country, runwayLength from Airport;`
return await this.all<AirportModel>(sql);
}
static async getIcaoCodes() : Promise<string[]>{
const sql = `select icao from Airport;`
return await this.all<string>(sql);
}
}