Skip to content

Commit

Permalink
Update booking.service.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
DFanso committed Jan 4, 2024
1 parent d55cf93 commit 8ec6265
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions server/src/booking/booking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Model } from 'mongoose';
import { CreateBookingDto } from './dto/create-booking.dto';
import { UpdateBookingDto } from './dto/update-booking.dto';
import { Booking, BookingDocument } from './entities/booking.entity';
import { ShowTimesService } from 'src/show-times/show-times.service';
import { PaypalService } from 'src/paypal/paypal.service';
import { MoviesService } from 'src/movies/movies.service';
import { ShowTimesService } from '../show-times/show-times.service';
import { PaypalService } from '../paypal/paypal.service';
import { MoviesService } from '../movies/movies.service';

@Injectable()
export class BookingService {
Expand Down Expand Up @@ -74,6 +74,25 @@ export class BookingService {
return bookings;
}

async findAllForUser(filter = {}): Promise<Booking[]> {
const bookings = await this.bookingModel
.find(
filter,
Object.keys(this.bookingModel.schema.obj)
.map((key) => key)
.join(' '),
)
.populate('userId')
.populate('movieId')
.populate('showTimeId')
.exec();

if (bookings.length === 0) {
throw new NotFoundException('No booking found matching the criteria');
}
return bookings;
}

async findOne(filter: any): Promise<BookingDocument | null> {
const booking = await this.bookingModel
.findOne(
Expand Down

0 comments on commit 8ec6265

Please sign in to comment.