title: NestJS TypeORM MongoDB can not use find or FindOne to search repository
body: <p>I'm working on a project with NestJs and TypeORM with MongoDB. Earlier we were working with express and mongoose and to find results in an array column we were using something like this :</p>
  <p>I'm working on creating a REST API using nestJS + TypeORM and MongoDB. The problem I am having is whenever I make a GET call to findOne or find all items in an entity/table it results in an error either saying Cannot read property 'prototype' of undefined or TypeError: Right-hand side of 'instanceof' is not an object.</p>
  <p>My Entity</p>
  <pre><code>@Entity({ name: 'discordconfigs' })
  export class DiscordConfig extends BaseEntity {
    @ObjectIdColumn()
    _id: ObjectID;
  
    @Column()
    clientId: string;
  }
  </code></pre>
  <p>DI for the REPO (Inside Constructor in service file)</p>
  <pre><code>@InjectRepository(DiscordConfig)
      private guildConfigRepository: MongoRepository&lt;DiscordConfig&gt;,
  </code></pre>
  <p>Usually, when using NestJS + TypeORM with an SQL database I can use this code snippet below to return all items in the array. Doing this with MongoDB results in an error  Cannot read property 'prototype' of undefined and does not return anything.
  <code>return this.guildConfigRepository.find();</code></p>
  <p>I can change the above to this and it will return the required data back to me but will result in the same error being thrown instead I think it is just a warning instead of an error.</p>
  <pre><code>return await this.guildConfigRepository
        .createCursor(this.guildConfigRepository.find())
        .toArray(); 
  </code></pre>
  <p>If I want to return a specific item then I have tried to use this but I get an error TypeError: Right-hand side of 'instanceof' is not an object. I console logged + checked the type of the parameter coming in and it was the correct data I inputted as a parameter and also a string.</p>
  <p><code>return await this.guildConfigRepository.findOne({ clientId });</code></p>
  <p>I am able to POST data and save it into the database without causing any errors. If I change my database type to an MYSQL database and call the repository using the normal TypeORM way then I get no errors.</p>
  <p>How would I fix this using typeORM or would it be easier using mongoose. I was considering switching to mongoose however I wanted to get typeORM working since it works natively with nestJS.</p>
  <p>Here is how I connect to the DB (Inside Imports in App.Module)</p>
  <pre><code>    TypeOrmModule.forRoot({
        type: 'mongodb',
        url: 'mongoURI',
        database: 'database',
        entities: entities,
        synchronize: true,
      }),
  </code></pre>
  <p>if I switch it to a MYSQL database with connection settings like this my API works without any errors.</p>
  <pre><code>    TypeOrmModule.forRoot({
        type: 'mysql',
        host: 'ipaddress',
        port: 3306,
        username: 'userLogin',
        password: 'userPassword',
        database: 'databaseName',
        entities: entities,
        synchronize: true,
      }),
  </code></pre>