These are chat archives for Automattic/mongoose

Apr 2019
Wyatt Carss
Apr 11 16:46

new question: using mongoose 5.0.15, I have a Schema with a non-required field that's an array of references to another collection, and calling .findOne() to get a document with that field missing from it seems to fill the field in with an empty array, but if I .populate that document, it seems to omit the field entirely.

Does this difference seem like expected behaviour? I'm kind of surprised that findOne fills the array in given it's a non-required field, but I'm actually hoping populate could do the same. (If this is too deep in the weeds/is a feature request, I can file an issue on the github project)