title: Nest can't resolve dependencies of the BaseRepository (?). Please make sure that the argument Object at index [0] is available in the RegisterModule
body: <p>I cannot understand why I'm getting this error, while the code seems correct t me.</p>
  <p>I have my <code>BaseRepository&lt;T= any&gt;</code> in nest.js application where I can pass only the document.</p>
  <p>I'm trying to build a module that implements register by email logic.</p>
  <p>The error states in the title of the question.</p>
  <p>Here is my code, please help me, I don't understand what am I doing wrong.</p>
  <p><code>register.module.ts</code></p>
  <pre><code>import { Module } from &quot;@nestjs/common&quot;;
  import { MongooseModule } from &quot;@nestjs/mongoose&quot;;
  import { Creator, CreatorDocument, CreatorSchema } from '../data/models/Creator'
  import { BaseRepository } from &quot;../repositories/BaseRepository&quot;;
  import { RegisterController } from &quot;../controllers/register.controller&quot;;
  import { RegisterService } from &quot;../services/register.service&quot;;
  import { RegisterMapper } from '../mappers/register.mapper'
  
  @Module({
      imports: [
          MongooseModule.forFeature([{ name: Creator.name, schema: CreatorSchema }]),
      ],
      controllers: [RegisterController],
      providers: [
        BaseRepository,
        RegisterMapper,
          {
              provide: RegisterService,
              useFactory: async (
                  repository: BaseRepository,
                  mapper: RegisterMapper
              ) =&gt; {
                  return new RegisterService(repository, mapper)
              },
              inject: [BaseRepository, RegisterMapper]
          }
      ],
      exports: []
  })
  
  export class RegisterModule {}
  
  </code></pre>
  <p><code>register.controller.ts</code></p>
  <pre><code>import { Body, Controller, HttpStatus, Post } from '@nestjs/common'
  import {RegisterService} from &quot;../services/register.service&quot;;
  import {RegisterDto} from &quot;../types/dtos/register.dto&quot;;
  
  
  @Controller()
  export class RegisterController {
      constructor(
          private service: RegisterService
      ) { }
  
      @Post('/api/register')
      async register(@Body() registerDTO: RegisterDto) {
        await this.service.createAccount(registerDTO)
        return HttpStatus.OK
      }
  }
  </code></pre>
  <p><code>register.service.ts</code></p>
  <pre><code>import {BaseRepository} from &quot;../repositories/BaseRepository&quot;;
  import { Creator, CreatorDocument } from '../data/models/Creator'
  import {RegisterDto} from &quot;../types/dtos/register.dto&quot;;
  import {Injectable} from &quot;@nestjs/common&quot;;
  import { RegisterMapper } from '../mappers/register.mapper'
  import { errors } from '../errors'
  import { mailer } from '../utils/nodemailer'
  
  @Injectable()
  export class RegisterService {
      constructor(
        private readonly repository: BaseRepository&lt;Creator&gt;,
        private readonly mapper: RegisterMapper
      ) { }
  
      async createAccount (doc: RegisterDto) {
        const emailExist = await this.existByEmail(doc.email)
        if (emailExist) {
          return errors.EMAIL_EXIST()
        }
        const created = await this.repository.create(this.mapper.toDomain(doc))
        await mailer(doc.email)
        return created
      }
  
      private async existByEmail(email: string): Promise&lt;boolean&gt; {
        console.log(email)
        console.log(this.repository)
        const response = await this.repository.get({email}, {})
        return !!response.email;
      }
  }
  
  </code></pre>
  <p><code>register.mapper.ts</code></p>
  <pre><code>import { Mapper } from '../types/interfaces/mapper'
  import { Creator } from '../data/models/Creator'
  import { RegisterDto } from '../types/dtos/register.dto'
  import { UserRole } from '../types/enums/UserRole'
  import { Injectable } from '@nestjs/common'
  
  @Injectable()
  export class RegisterMapper implements Mapper&lt;Creator&gt; {
      toDomain(dto: RegisterDto): Creator {
          const creator = new Creator()
          creator.name = dto.name
          creator.email = dto.email
          creator.password = dto.password
          creator.asset = dto.asset
          creator.description = dto.description
          creator.isVerified = false
          creator.type = UserRole.CREATOR
          creator.links = dto.links
          creator.notifications = dto.notifications
  
          return creator
      }
  
      toDTO(domain: Creator): RegisterDto {
          return undefined;
      }
  
  }
  </code></pre>
  <p><code>base.repository.ts</code></p>
  <pre><code>import { Injectable } from '@nestjs/common';
  import { ModelType } from '@typegoose/typegoose/lib/types'
  import { DuplicateKeyError } from &quot;../errors/DuplicateKeyError&quot;
  import { DocumentNotFoundError } from &quot;../errors/DocumentNotFoundError&quot;
  
  @Injectable()
  export class BaseRepository&lt;T = any&gt; {
      constructor(
          private Model: any
      ) {
      }
  
      async create (object): Promise&lt;T&gt; {
          const Model = this.Model
  
          const uniqueKey = Model.getUniqueKey ? Model.getUniqueKey() : null
          if (uniqueKey &amp;&amp; object[uniqueKey]) {
              const criteria = {
                  [uniqueKey]: object[uniqueKey]
              }
              const existing = await Model.findOne(criteria)
              if (existing) {
                  throw new DuplicateKeyError(Model, criteria)
              }
          }
  
          const model = new Model(object)
          return model.save()
      }
  
      async update (criteria, object, options = {}) {
          const Model = this.Model
  
          const uniqueKey = Model.getUniqueKey ? Model.getUniqueKey() : '_id'
  
          const data = { ...object }
          delete data[uniqueKey]
          delete data.createdAt
  
          return this.updateRaw(criteria, { $set: { ...data } }, options)
      }
  
      async updateRaw (criteria, data, options = {}) {
          const query = this._getDbQuery(criteria, options)
          const result = await this.Model.findOneAndUpdate(query, data, { new: true, ...options })
  
          if (!result) {
              throw new DocumentNotFoundError(this.Model, query)
          }
  
          return result
      }
  
      async save (modelInstance) {
          return modelInstance.save()
      }
  
      async get (criteria, options: any = {}): Promise&lt;T | undefined&gt; {
          console.log(this._getDbQuery(criteria, options))
          const promise = this.Model.findOne(this._getDbQuery(criteria, options))
  
          if (options.select) {
              promise.select(options.select)
          }
  
          return promise
      }
  
      async find (criteria, options): Promise&lt;ReturnType&lt;ModelType&lt;T&gt;['find']&gt;&gt; {
          return this.Model.find(this._getDbQuery(criteria, options))
      }
  
      async resolve (criteria): Promise&lt;T&gt; {
          return this.Model.resolve(this._getDbQuery(criteria))
      }
  
      async count (query) {
          return this.Model.countDocuments(this._getDbQuery(query))
      }
  
      async delete (criteria) {
          return this.Model.remove(this._getDbQuery(criteria))
      }
  
      _getDbQuery (criteria, options: any = {}) {
          if ('getDbQuery' in criteria) {
              const dbQuery = criteria.getDbQuery(options)
              return 'find' in dbQuery
                  ? dbQuery.find
                  : dbQuery
          } else {
              return criteria
          }
      }
  
  }
  </code></pre>