briankircho / mongoose-schema-extend

mongoose schema inheritance and discriminator key extension
MIT License
299 stars 46 forks source link

Auto-casting for subdocument._id not work #31

Open Crotery opened 9 years ago

Crotery commented 9 years ago

I have a schema { ... windows: [{name:String}] ... } If I run Model.find({windows._id:'string'}) everything is ok, mongoose is sending query {"windows._id":ObjectId('string')} and returns records;

If I extend the schema somehow (ex. just {S_V:Number}), find() do not return anything, because mongoose is sending query {'windows._id':'string'}, which searches for string-type _ids and fails to find any.

This issue contains more information and real code example: https://github.com/Automattic/mongoose/issues/3364#issuecomment-141353516

sieira commented 8 years ago

May have to fix the cloning stuff, I'll check that