diff --git a/backend/src/infrastructure/database/mongoDB/generic-document.repository.ts b/backend/src/infrastructure/database/mongoDB/generic-document.repository.ts index 0c914317..06e4d7f5 100644 --- a/backend/src/infrastructure/database/mongoDB/generic-document.repository.ts +++ b/backend/src/infrastructure/database/mongoDB/generic-document.repository.ts @@ -113,7 +113,7 @@ export abstract class GenericDocumentRepository imp const queryOptions: any = { new: true, }; - if (options.session) { + if (options?.session) { queryOptions.session = options.session; } const result = await this.DocumentModel.findByIdAndUpdate(filterQuery, update, queryOptions); @@ -134,7 +134,7 @@ export abstract class GenericDocumentRepository imp upsert: true, new: true, }; - if (options.session) { + if (options?.session) { queryOption.session = options.session; } const result = await this.DocumentModel.findOneAndUpdate(filterQuery, document, { session: options.session });