Hello,
I'm using Mongoose 3.6.4 and have noticed some behaviour that I couldn't find any documentation for.
If I have a document that has a field populate()'d, when I call toObject() with a custom transform function, it will call the toObject() function that I have set on the populated object. However, the toObject() on the original document gets called with the object that got returned.
The docs mention a way to determine when it is a sub-document that is having toObject() called, but how can I determine if it is a populated document or not?
Currently my toObject function has a lot of "if (doc.user_id && !doc.user_id._id) ret.user_id = doc.user_id.toString()"
Thanks,
Jon