mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
make getBookings parametrizable
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as mongoose from 'mongoose'
|
||||
import { getYear } from 'date-fns'
|
||||
import BookerModel, { Booker } from './booker'
|
||||
import BookingModel, { Booking } from './booking'
|
||||
import BillModel, { Bill } from './bill'
|
||||
@@ -31,10 +32,14 @@ export async function getBookingByUUID(uuid: string) {
|
||||
return BookingModel.findOne({ uuid })
|
||||
}
|
||||
|
||||
export async function getBookings() {
|
||||
export async function getBookings({
|
||||
status = [BOOKING_STATUS.CONFIRMED, BOOKING_STATUS.REQUESTED],
|
||||
startDateGreaterThan = '2000-01-01T00:00:00Z',
|
||||
}: { status?: BOOKING_STATUS[]; startDateGreaterThan?: string } = {}) {
|
||||
await connect()
|
||||
return await BookingModel.find({
|
||||
status: { $in: [BOOKING_STATUS.REQUESTED, BOOKING_STATUS.CONFIRMED] },
|
||||
status: { $in: status },
|
||||
startDate: { $gte: startDateGreaterThan },
|
||||
})
|
||||
.populate('booker')
|
||||
.exec()
|
||||
|
||||
Reference in New Issue
Block a user