@@ -420,8 +420,10 @@ export class MongoDriver implements Driver {
420420 }
421421
422422 // Pass session for transactional operations only if it exists
423- const result = options ?. session
424- ? await collection . insertOne ( mongoDoc , { session : options . session } )
423+ // Support both 'transaction' and 'session' option keys for compatibility
424+ const session = options ?. transaction || options ?. session ;
425+ const result = session
426+ ? await collection . insertOne ( mongoDoc , { session } )
425427 : await collection . insertOne ( mongoDoc ) ;
426428
427429 // Return API format document (convert _id to id)
@@ -456,8 +458,10 @@ export class MongoDriver implements Driver {
456458
457459 // Use findOneAndUpdate to return the updated document
458460 const mongoOptions : FindOneAndUpdateOptions = { returnDocument : 'after' } ;
459- if ( options ?. session ) {
460- mongoOptions . session = options . session ;
461+ // Support both 'transaction' and 'session' option keys for compatibility
462+ const session = options ?. transaction || options ?. session ;
463+ if ( session ) {
464+ mongoOptions . session = session ;
461465 }
462466
463467 const result = await collection . findOneAndUpdate (
@@ -473,8 +477,10 @@ export class MongoDriver implements Driver {
473477 async delete ( objectName : string , id : string | number , options ?: any ) {
474478 const collection = await this . getCollection ( objectName ) ;
475479 // Pass session for transactional operations only if it exists
476- const result = options ?. session
477- ? await collection . deleteOne ( { _id : this . normalizeId ( id ) } , { session : options . session } )
480+ // Support both 'transaction' and 'session' option keys for compatibility
481+ const session = options ?. transaction || options ?. session ;
482+ const result = session
483+ ? await collection . deleteOne ( { _id : this . normalizeId ( id ) } , { session } )
478484 : await collection . deleteOne ( { _id : this . normalizeId ( id ) } ) ;
479485 return result . deletedCount ;
480486 }
@@ -519,14 +525,14 @@ export class MongoDriver implements Driver {
519525 const update = isAtomic ? updateData : { $set : updateData } ;
520526
521527 const result = await collection . updateMany ( filter , update ) ;
522- return result . modifiedCount ;
528+ return { modifiedCount : result . modifiedCount } ;
523529 }
524530
525531 async deleteMany ( objectName : string , filters : any , options ?: any ) : Promise < any > {
526532 const collection = await this . getCollection ( objectName ) ;
527533 const filter = this . mapFilters ( filters ) ;
528534 const result = await collection . deleteMany ( filter ) ;
529- return result . deletedCount ;
535+ return { deletedCount : result . deletedCount } ;
530536 }
531537
532538 async aggregate ( objectName : string , pipeline : any [ ] , options ?: any ) : Promise < any [ ] > {
0 commit comments