diff --git a/src/event/event.repository.ts b/src/event/event.repository.ts index 5fd17be..9d7bcb9 100644 --- a/src/event/event.repository.ts +++ b/src/event/event.repository.ts @@ -1,5 +1,5 @@ import { Inject, Injectable } from '@nestjs/common'; -import { Model } from 'mongoose'; +import mongoose, { Model } from 'mongoose'; import { CreateEventDto } from './dto/create-event.dto'; import { Event } from './entities/event.entity'; @@ -17,7 +17,9 @@ export class EventRepository { } findOne(eventId: string): Promise { - return this.eventModel.findById(eventId).exec() as Promise; + if (mongoose.Types.ObjectId.isValid(eventId)) { + return this.eventModel.findById(eventId).exec() as Promise; + } } update(eventId: string, event: Event): Promise {