BUG - Subdocument mapping that has select: false
results in MongoDB Server Error
#11698
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Bug Report
Before creating an issue please make sure you are using the latest version of mongooseGetting aOperaion ... timed out after 10000ms
error? Read this FAQ entry: https://mongoosejs.com/docs/faq.html#operation-buffering-timed-outGetting ax.$__y is not a function
error? Read this FAQ entry: https://mongoosejs.com/docs/faq.html#not-a-functionWhat is the current behavior?
When a document maps a subdocument — Map
({ field: 'hello', number: 0 }, { field: 'world', number: 1 } )
The subdocument contains a property with
select: false
for ex.number
—Map({ field: 'hello' }, { field: 'world' } )
Mongoose will query:
Resulting in a MongoDB error response:
FieldPath field names may not start with '$'. Consider using $getField or $setField.
Steps to reproduce
Console log
What is the expected behavior?
No errors are thrown, document is fetched with the subdocuments. The subdocument will query
select: false
, as expected, using the property.What are the versions of Node.js, Mongoose and MongoDB you are using?
package.json
"mongoose": "^6.3.0"
Node.js
v16.14.2
The text was updated successfully, but these errors were encountered: