Recently delving into NestJs, I followed the configuration instructions outlined in https://docs.nestjs.com/techniques/database, but I am struggling to identify the issue within my code.
Error: Nest cannot resolve dependencies of the AdminRepository (?). Please ensure that the argument Connection at index [0] is available in the TypeOrmModule context.
Admin Module:
import { Module } from '@nestjs/common';
import {Admin} from "../entities/Admin";
import {TypeOrmModule} from '@nestjs/typeorm';
import {AdminService} from "./admin.service";
import {AdminController} from "./admin.controller";
@Module({
imports:[TypeOrmModule.forFeature([Admin])],
exports: [TypeOrmModule],
providers: [AdminService],
controllers: [AdminController]
})
export class AdminModule {}
AdminController:
import { Controller } from '@nestjs/common';
@Controller('admin')
export class AdminController {}
AdminService:
import { Injectable } from '@nestjs/common';
import { Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { Admin } from '../entities/Admin';
@Injectable()
export class AdminService {
constructor(
@InjectRepository(Admin)
private readonly adminRepository:Repository<Admin>
) {}
}
App Module:
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { LoginController } from './login/login.controller';
import { RegisterController } from './register/register.controller';
import { ContactController } from './contact/contact.controller';
import { AppService } from './app.service';
import { LoginService } from './login/login.service';
import { ContactService } from './contact/contact.service';
import { RegisterService } from './register/register.service';
import { AdminModule } from './admin/admin.module';
@Module({
imports: [AdminModule],
controllers: [AppController, LoginController, RegisterController, ContactController],
providers: [AppService, LoginService, ContactService, RegisterService],
})
export class AppModule {}