mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
infer return type of functions
This commit is contained in:
10
db/index.ts
10
db/index.ts
@@ -1,12 +1,12 @@
|
||||
import * as mongoose from 'mongoose'
|
||||
import BookerModel, { Booker } from './booker'
|
||||
import BookingModel, { Booking } from './booking'
|
||||
import BookingModel, { Booking, BookingDocument } from './booking'
|
||||
import BillModel, { Bill } from './bill'
|
||||
import { BOOKING_STATUS } from './enums'
|
||||
|
||||
let connectedPromise: Promise<typeof mongoose>
|
||||
|
||||
function connect() {
|
||||
function connect(): Promise<typeof mongoose> {
|
||||
if (connectedPromise) {
|
||||
return
|
||||
}
|
||||
@@ -20,12 +20,12 @@ function connect() {
|
||||
return connectedPromise
|
||||
}
|
||||
|
||||
export async function getBookedDays(uuidsToIngore?: string[]) {
|
||||
export async function getBookedDays(uuidsToIngore?: string[]): Promise<string[]> {
|
||||
await connect()
|
||||
return BookingModel.findBookedDays(uuidsToIngore)
|
||||
}
|
||||
|
||||
export async function getBookingByUUID(uuid: string) {
|
||||
export async function getBookingByUUID(uuid: string): Promise<BookingDocument> {
|
||||
await connect()
|
||||
return BookingModel.findOne({ uuid })
|
||||
}
|
||||
@@ -33,7 +33,7 @@ export async function getBookingByUUID(uuid: string) {
|
||||
export async function getBookings({
|
||||
status = [BOOKING_STATUS.CONFIRMED, BOOKING_STATUS.REQUESTED],
|
||||
startDateGreaterThan = '2000-01-01T00:00:00Z',
|
||||
}: { status?: BOOKING_STATUS[]; startDateGreaterThan?: string } = {}) {
|
||||
}: { status?: BOOKING_STATUS[]; startDateGreaterThan?: string } = {}): Promise<BookingDocument[]> {
|
||||
await connect()
|
||||
return await BookingModel.find({
|
||||
status: { $in: status },
|
||||
|
||||
Reference in New Issue
Block a user