| 1 | import { prisma } from 'src/db'; |
| 2 | |
| 3 | import { Injectable } |
| 4 | import { createId } |
| 5 | |
| 6 | @Injectable() |
| 7 | export class AirportsService |
| 8 | async getAirports({ |
| 9 | const res = |
| 10 | omit: { createdAt: true |
| 11 | where: { |
| 12 | type: { not: ' |
| 13 | iataCode: { not: null |
| 14 | ...(search |
| 15 | ? { |
| 16 | OR: [ |
| 17 | { |
| 18 | name: { |
| 19 | contains: search, |
| 20 | mode: 'insensitive', |
| 21 | }, |
| 22 | }, |
| 23 | { |
| 24 | ident: { |
| 25 | contains: search, |
| 26 | mode: 'insensitive', |
| 27 | }, |
| 28 | }, |
| 29 | { |
| 30 | iataCode: { |
| 31 | contains: search, |
| 32 | mode: 'insensitive', |
| 33 | }, |
| 34 | }, |
| 35 | { |
| 36 | municipality: { |
| 37 | contains: search, |
| 38 | mode: 'insensitive', |
| 39 | }, |
| 40 | }, |
| 41 | ], |
| 42 | } |
| 43 | : undefined), |
| 44 | }, |
| 45 | }); |
| 46 | return res; |
| 47 | } |
| 48 | |
| 49 | async createAirport(body |
| 50 | return await prisma |
| 51 | data: { ...body |
| 52 | }); |
| 53 | } |
| 54 | } |