You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently integrating nestjs/mongoose into our project and I was expecting Documents to retain the key order as defined in the schema, but instead, key order is reversed. Some time ago, mongoose was doing this on purpose, for some performance optimisation reason, and a retainKeyOrder schema option existed to prevent that.
Is there an existing issue for this?
Current behavior
I am currently integrating nestjs/mongoose into our project and I was expecting Documents to retain the key order as defined in the schema, but instead, key order is reversed. Some time ago, mongoose was doing this on purpose, for some performance optimisation reason, and a
retainKeyOrder
schema option existed to prevent that.Since version 5, this behaviour was removed from mongoose (https://mongoosejs.com/docs/migrating_to_5.html#retain-key-order), but I am experiencing it when I define the schema through decorators with
@nestjs/mongoose
.Is there any known reason for this?
Minimum reproduction code
https://gist.github.com/cristian-moreno-ruiz/abcfe808067ecd894b8ed328606d97f2
Steps to reproduce
await this.accountModel.insertMany(account);
Expected behavior
I would expect to get the document with original key order:
But I get:
Package version
9.0.2
mongoose version
6.2.5
NestJS version
8.2.5
Node.js version
14.16.1
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: