kpfromer / nestjs-typegoose

Typegoose with NestJS
https://kpfromer.github.io/nestjs-typegoose/
MIT License
291 stars 73 forks source link

InjectConnection not supported? #499

Open bneigher opened 1 year ago

bneigher commented 1 year ago

I'm looking for similar behavior as @nestjs/mongoose:

import { Injectable, Logger } from '@nestjs/common';
import { InjectConnection } from '@nestjs/mongoose';

@Injectable()
export class MyService {
  private readonly logger = new Logger(MyService.name);

  // eslint-disable-next-line no-useless-constructor
  constructor(
    @InjectConnection() private dbConnection: Connection,
  ) {}

  async test() {
    const transaction = await this.dbConnection.startSession();
    await transaction.withTransaction(async () => { ... /* my transactions */ ... })
    transaction.endSession();
    return
  }
}

Is this something that we can add to the lib?