@@ -27,13 +27,15 @@ import { MongoPersistence } from './persistence.js';
2727import { MongoClient } from './client/client.js' ;
2828import { DeleteCommand } from './client/command/delete.js' ;
2929import { MongoQueryResolver } from './query.resolver.js' ;
30- import { MongoDatabaseTransaction } from './client/connection.js' ;
30+ import { MongoDatabaseTransaction , MongoDatabaseTransactionMonitor } from './client/connection.js' ;
3131import { CreateIndex , CreateIndexesCommand } from './client/command/createIndexes.js' ;
3232import { DropIndexesCommand } from './client/command/dropIndexes.js' ;
3333import { CreateCollectionCommand } from './client/command/createCollection.js' ;
3434import { entity , ReceiveType , ReflectionClass , resolveReceiveType } from '@deepkit/type' ;
3535import { Command } from './client/command/command.js' ;
3636import { AggregateCommand } from './client/command/aggregate.js' ;
37+ import { EventDispatcher } from '@deepkit/event' ;
38+ import { Logger } from '@deepkit/logger' ;
3739
3840export class MongoDatabaseQueryFactory extends DatabaseAdapterQueryFactory {
3941 constructor (
@@ -114,6 +116,7 @@ export class MongoDatabaseAdapter extends DatabaseAdapter {
114116 public readonly client : MongoClient ;
115117
116118 protected ormSequences : ReflectionClass < any > ;
119+ protected transactionMonitor : MongoDatabaseTransactionMonitor = new MongoDatabaseTransactionMonitor ( this . logger ) ;
117120
118121 constructor (
119122 connection : string | MongoClient ,
@@ -130,6 +133,17 @@ export class MongoDatabaseAdapter extends DatabaseAdapter {
130133 this . ormSequences = ReflectionClass . from ( OrmSequence ) ;
131134 }
132135
136+ setEventDispatcher ( eventDispatcher : EventDispatcher ) {
137+ super . setEventDispatcher ( eventDispatcher ) ;
138+ this . client . setEventDispatcher ( eventDispatcher ) ;
139+ }
140+
141+ setLogger ( logger : Logger ) {
142+ super . setLogger ( logger ) ;
143+ this . client . setLogger ( logger ) ;
144+ this . transactionMonitor . logger = logger ;
145+ }
146+
133147 rawFactory ( session : DatabaseSession < this> ) : MongoRawFactory {
134148 return new MongoRawFactory ( session , this . client ) ;
135149 }
@@ -147,7 +161,7 @@ export class MongoDatabaseAdapter extends DatabaseAdapter {
147161 }
148162
149163 createTransaction ( session : DatabaseSession < this> ) : MongoDatabaseTransaction {
150- return new MongoDatabaseTransaction ;
164+ return new MongoDatabaseTransaction ( this . transactionMonitor ) ;
151165 }
152166
153167 isNativeForeignKeyConstraintSupported ( ) {
0 commit comments