Automattic / Automattic/mongoose
Option to not merge the base schema onto the input schema for `Model.discriminator`
- Dominant language
- JavaScript
- Stars
- 27.5k
- Forks
- 4k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 35
Description
### Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the feature has not already been requested
### 🚀 Feature Proposal
A option to disable the current behavior of always merging the base schema onto the input schema
### Motivation
Because when manually cloning the schemas beforehand this may result in duplicate things, or if not cloned at all from the base schema but with the same schema definition (not schema instance), it would create duplicate entries (for example hooks)
the current behavior runs into things like #12472
For example the documentation at [Apply Plugins Before Compiling Models](https://mongoosejs.com/docs/plugins.html#apply-plugins-before-compiling-models) would not apply anymore with the current implementation
### Example
With the option it would be up to the user to clone the schema or define a new schema from the ground up (with maybe a same schema definition), but still apply all required options for a discriminator
---
fixes #12472
Contributor guide
Research direction
Start at the Model.discriminator entry point and review the current base-schema merge behavior described in this issue. Use the Apply Plugins Before Compiling Models documentation and related issue #12472 to understand the duplicate-plugin problem. Done means users can opt out of the merge while still applying the required discriminator options.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, node.js
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100