Search code examples
mongodbmongoosenestjsnestnestjs-mongoose

Documentation of @nestjs/mongoose


I started learning NestJS, by reading documentation. currently, I'm using the @nestjs/mongoose package for MongoDB. unforunatley I can't find any documentation about this package. the only docs I found is this https://docs.nestjs.com/techniques/mongodb however, it's missing lots of information, such as creating an index for the schema. where can I find additional information? how people on stack overflow know some of the answers if they are not in the documentation

edit: I mean documentation of @nestjs/mongoose


Solution

  • @nestjs/mongoose mostly is a simple wrapper around mongoose for Nest's DI context. Nest does have additional decorators, like @Schema() and @Prop() to allow for creating a class based representation of the schema and then the SchemaFactory.createForClass method to create the schema object that mongoose will later use. Any properties you can normally set when creating a prop, as described in the mongoose documentation should be passable to the @Prop(). The Typescript types are there to help you, and should give you good intellisense on what is and isn't possible.

    Other than that, the Nest team is slowly working on getting some API docs out, but it's a very large initiative that will take a lot of time.