nestjs / mongoose

Mongoose module for Nest framework (node.js) 🍸
https://nestjs.com
MIT License
528 stars 118 forks source link

Type error when creating index: Argument of type '{ xpto : 1}' is not assignable to parameter of type 'xpto' does not exist in type 'IndexSpecification'. #983

Closed lucasltv closed 3 years ago

lucasltv commented 3 years ago

Error when creating schema index.


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When configuring schema.index at object instance returned by SchemaFactory.createForClass its returns a error during dev runtime. The type of first argument of schema was any and now has type of IndexSpecification.

Expected behavior

I always declare a compound index using this sintax XptoSchema.index({ field1 : 1, field2 : 1 },{ unique:true }) but now I'm getting this trouble described below.

Minimal reproduction of the problem with instructions

user model ts — kit-talk-api-v1 2021-08-10 at 7 13 35 PM

What is the motivation / use case for changing the behavior?

index d ts — api-v1 2021-08-11 at 12 37 41 AM

Environment


Nest version: X.Y.Z


    "@nestjs/common": "^8.0.6",
    "@nestjs/config": "^1.0.1",
    "@nestjs/core": "^8.0.6",
    "@nestjs/mongoose": "^8.0.0"

For Tooling issues:
- Node version: XX  
- Platform:  

NODE: v14.16.0
Platform: MAC OS BIG SUR

Others:

kamilmysliwiec commented 3 years ago

Report this issue in the mongoose repository https://github.com/Automattic/mongoose