Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow defining index on base model that applies to all discriminators #14176

Merged
merged 2 commits into from Dec 21, 2023

Conversation

peplin
Copy link
Contributor

@peplin peplin commented Dec 13, 2023

Summary

We would like to define an index on a base model, with a partial filter so that it only applies to discriminators. It's not a discriminator index (as described in #11424), because it's not specific to any one child.

We were surprised that these indexes were being silently ignored during syncing, and wondered if you are open to changing the behavior. Alternatively, please let me know if this key is just not necessary in the filter. I'm new to both Mongoose and MongoDB. Thanks!

Examples

I've added a test, where you can see that getRelatedIndexes no longer skips indexes on base models with the discriminator key, if it's just checking existence:

__t: { $exists: true }

@peplin peplin force-pushed the discriminator-existence-on-index branch from e0b9eed to bfed8a6 Compare December 13, 2023 20:52
@vkarpov15 vkarpov15 added this to the 8.0.4 milestone Dec 21, 2023
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a quick change to avoid all partial filter expressions that aren't an explicit $eq. But otherwise LGTM, thanks 👍

@vkarpov15 vkarpov15 merged commit 9c17773 into Automattic:master Dec 21, 2023
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants