import { Class , getQueryServiceToken } from '@nestjs-query/core' ; import { FactoryProvider } from '@nestjs/common' ; import { getRepositoryToken } from '@nestjs/typeorm' ; import { Repository , Connection , ConnectionOptions } from 'typeorm' ; import { TypeOrmQueryService } from './services' ; function createTypeOrmQueryServiceProvider < Entity > ( EntityClass , connection ? ) { return { provide : getQueryServiceToken ( EntityClass ) , useFactory ( repo ) { return new TypeOrmQueryService ( repo ) ; } , inject : [ getRepositoryToken ( EntityClass , connection ) ] , } ; } export const createTypeOrmQueryServiceProviders = ( entities , connection ? ) : FactoryProvider [ ] => entities . map ( ( entity ) => createTypeOrmQueryServiceProvider ( entity , connection ) ) ;