1

So, I am not using TypeOrm but mongoose for mongodb. The interfaces I create has no benefits for using Pipes because interface is typescript's behaviour and not Javascript's.

I have schema and Document but that too doesn't get into a lot of function arguments.
I get errors like

'UserDocument' only refers to a type, but is being used as a value here

(above UserDocument is created in the schema file with export type UserDocument = User & Document;)

What is the good practice if we are using mongoose ORM and the documents we make (with export type UserDocument = User & Document; or by making interfaces) are not available for most of the functions in nestJS.

Abhishek Kumar
  • 820
  • 12
  • 16
  • 1
    Where are you using `UserDocument`? It's probably not what you're meaning to reference. – Jay McDoniel May 08 '21 at 22:12
  • So should I create a new class with the same property as UserShema has, Isn't it add too much redundant code for multiple schemas while using mongoose. – Abhishek Kumar May 09 '21 at 12:20
  • Would you like to recommend a good repository that follow good code practices in nestjs without using TypeORM. Or TypeORM is the most defacto thing that I should learn? – Abhishek Kumar May 09 '21 at 12:21
  • 1
    [I feel that Nest's docs show a good basic example](https://docs.nestjs.com/techniques/mongodb). TypeORM is... well it's something. I'd advise [MikroORM](https://github.com/mikro-orm/nestjs) or [Primsa](https://www.prisma.io/) over TypeORM though. But if you're working with Mongo, the `@nestjs/mongoose` package is good or using [`typegoose`](https://github.com/kpfromer/nestjs-typegoose) is good – Jay McDoniel May 09 '21 at 17:48

0 Answers0