No global plugins applied when using mergePlugins
on discriminators
#12696
Labels
discussion
If you have any thoughts or comments on this issue, please share them!
Milestone
Prerequisites
Issue
(Continuation of #12604)
Since #12613 introduced a way to turn off the "overwrite of the plugins from the base schema", but now i noticed that no global plugins (
mongoose._applyPlugins
) are applied, which does not make the schemas the same as when calling withmongoose.model
.mongoose/lib/index.js
Lines 570 to 575 in c77dd1b
Test Code and Output
Reproduction Repository / Branch: https://github.com/typegoose/typegoose-testing/tree/testHooks672
Output with
mergeHooks: true
ormergePlugins: true
:Output with
mergeHooks: false
ormergePlugins: false
:Workaround is to add
mongoose._applyPlugins(discriminatorSchema)
before callingfrom.discriminator
, like:I opened this as "Other" with "discussion", because i am not sure if this wanted to be implemented as a "else" case of
mergeHooks
/mergePlugins
, or as a options or at all.PS: there also seems to be something wrong with
this.modelName
andthis.constructor.name
in thevalidate
hook or the types are wrong andthis
is not actually a fullDocument
.The text was updated successfully, but these errors were encountered: