alexsk / mongoose-intl

Mongoose schema plugin for multilingual fields
MIT License
74 stars 31 forks source link

Error when using .select() on a schema with intl fields #12

Closed yelworc closed 6 years ago

yelworc commented 7 years ago

I'm getting the following error when retrieving a document with a query containing a select() clause:

TypeError: Cannot read property 'hasOwnProperty' of undefined
    at Module.<anonymous> (.../node_modules/mongoose-intl/lib/mongoose-intl.js:62:32)
    at VirtualType.applyGetters (.../node_modules/mongoose/lib/virtualtype.js:77:25)
    at Module.Document.get (.../node_modules/mongoose/lib/document.js:953:19)
    at applyGetters (.../node_modules/mongoose/lib/document.js:2268:22)
    at Module.Document.$toObject (.../node_modules/mongoose/lib/document.js:2051:5)
    at Module.Document.toJSON (.../node_modules/mongoose/lib/document.js:2330:15)

The error occurs when one or more ìntl-enabled fields are not included in the selected fields.

I see that a similar error has been fixed in #4. Maybe this is a regression caused by the v3 refactoring (or in 3.0.1 with commit 9f21ac4)?

Package versions: mongoose@4.12.0, mongoose-intl@3.0.1

mixalistzikas commented 6 years ago

Any news about this bug?

alexsk commented 6 years ago

Fixed. Thank you for the reporting.