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

Remove HACK for discriminator hook / plugin cloning / overwrite #768

Closed
2 tasks done
hasezoey opened this issue Oct 27, 2022 · 4 comments
Closed
2 tasks done

Remove HACK for discriminator hook / plugin cloning / overwrite #768

hasezoey opened this issue Oct 27, 2022 · 4 comments
Labels

Comments

@hasezoey
Copy link
Member

hasezoey commented Oct 27, 2022

Remove the hack(s) made for not cloning hooks and overwriting plugins for discriminators

hacks done:

options: { ...rawOptions?.options, $isDiscriminator: true },

const mergedOptions = { ...ropt.options, ...overwriteOptions?.options };
if (!(mergedOptions.$isDiscriminator && mergedOptions.disablePluginsOnDiscriminator)) {
for (const plugin of plugins) {
logger.debug('Applying Plugin:', plugin);
sch.plugin(plugin.mongoosePlugin, plugin.options);
}
} else {
logger.info('Ignoring plugins because it is a discriminator and "disablePluginsOnDiscriminator" is set');
}

related mongoose issues:

Notes on why this hack might be needed

@hasezoey hasezoey added enhancement Improve an existing Feature cant fix This cant be fixed without external modules being updated labels Oct 27, 2022
@hasezoey hasezoey removed the cant fix This cant be fixed without external modules being updated label Nov 17, 2022
@hasezoey
Copy link
Member Author

will fix with 9.13.0

though there is still a slight workaround needed thanks to Automattic/mongoose#12696

@github-actions
Copy link

🎉 This issue has been resolved in version 9.13.0-beta.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This issue has been resolved in version 9.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@hasezoey
Copy link
Member Author

For anyone searching this and wanting the old behavior, see options enableMergePlugins and enableMergeHooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant