If I setup a Model with a discriminator key mongoose automatically prefixes all queries with the discriminator key.
But if I define some keys as index: true
the indexes that are created are not prefixed by the discriminator key. Instead they are simple indexes with a single key.
Isn't this suboptimal? Shouldn't all indexes be compound indexes of the discriminatorKey (e.G. __t
) and the key I want to index?
And if yes should I instead of defining indexes at the path level (via index: true
) prefer to set them like this:
Event.index({ __t: 1, type: 1 });