I have a schema like this:
    @Schema()
    export class Pais extends Document {
      @Prop(
        raw({
          codigo: { type: String, index: true, unique: true },
        }),
      )
      @Prop()
      descripcion: string;
    }
    
    export const PaisSchema = SchemaFactory.createForClass(Pais);
    
    PaisSchema.plugin(uniqueValidator, { message: `{PATH} debe ser único` });
By default nest.js add an 's' to the class name, so it would be 'paiss' for the collection, but I want the name to be 'paises'.
On the module I tried this:
    @Module({
      imports: [
        MongooseModule.forFeature([{ name: 'paises', schema: PaisSchema }]),
      ],
but it didn't work. How can I solve this problem?
i found a solution, just had to set the @Schema() decorator like this
@Schema({ collection: 'paises' })
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With