Description
Do you want to request a feature or report a bug?
Bug that's possibly a feature.
What is the current behavior?
A discriminator value is omitted when not a string.
Why is this a problem?
This is frustrating, as I'm unable to use any query operations such as $in, or an existing ObjectId.
I'm unsure why this is tied to only be a string, as it actually works well with either of the non-string values such as:
{$in: array}
or
ObjectId('xyz')
What is the expected behavior?
To be able to use non-string discriminators.
What are the versions of Node.js, Mongoose and MongoDB you are using?
Node v14.16.0
Mongoose v5.12.1
MongoDb v4.4.4
Code specific comment
I have identified the specific line of code which is causing the issue:
mongoose/lib/helpers/model/discriminator line 65.
let value = name;
if (typeof tiedValue == 'string' && tiedValue.length) {
value = tiedValue;
}
This can be updated to (or the logic omitted entirely):
let value = name;
value = tiedValue;
Other comments
Only thought is there's some sort of security concern?