Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When defining an index on a nested discriminator, mongoose knows to change the paths and apply the index on the parent, while properly locating the correct fields within the nested subdocument.
However, the partialFilterExpression
is not transformed properly.
Here's an example:
The index is defined like this and is part of an embedded schema (child of a parent schema):
{ matchday: 1, team: 1, "players.user": 1 },
{
unique: true,
partialFilterExpression: { "players.user": { $exists: 1 } },
},
Notice how the indexed fields correctly got nested under invites
, but the partialFilterExpression
was not updated.
If the current behavior is a bug, please provide the steps to reproduce.
Define an index like the above.
What is the expected behavior?
The partialFilterExpression
should be adjusted to point to the correct sub-paths. In the screenshot above, the computed result should be invites.players.user: { $exists: 1 }
.
Fixing this could be a breaking change if someone is relying on the currently broken behavior.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
mongoose 5.9.16