Closed Pacheco95 closed 4 years ago
In the documentation
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document } from 'mongoose'; export type CatDocument = Cat & Document; @Schema() export class Cat { @Prop() name: string; @Prop() age: number; @Prop() breed: string; } export const CatSchema = SchemaFactory.createForClass(Cat);
the model (CatDocument) is declared and exported as a separated type from schema (CatSchema), but in the example it is extending mongoose Document. What approach should I use? Is there any difference?
CatDocument
CatSchema
Document
https://github.com/nestjs/nest/blob/1b9341411707a545288421453cd899fbc5029e78/sample/06-mongoose/src/cats/schemas/cat.schema.ts#L5
The example was invalid, thanks for pointing that out! I've just pushed a commit with a fix.
In the documentation
the model (
CatDocument
) is declared and exported as a separated type from schema (CatSchema
), but in the example it is extending mongooseDocument
. What approach should I use? Is there any difference?https://github.com/nestjs/nest/blob/1b9341411707a545288421453cd899fbc5029e78/sample/06-mongoose/src/cats/schemas/cat.schema.ts#L5