You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently if you have Model and Submodel discriminating on the field "kind", and you do:
let doc = await Model.create({kind: "SubModel"})
You end up with an instance of SubModel as the result. However, if you do:
let doc = new Model({kind: "SubModel"})
Then doc is an instance of Model, not SubModel. While I understand the argument in the above issue that a polymorphic constructor is kind of confusing, it seems like this current situation is now even more confusing because one method of creating a new document will return SubModel, and the other will return Model.
In the docs, these two types of constructors are described as interchangeable and this difference in discriminator behaviour is not documented anywhere that I can find.
The text was updated successfully, but these errors were encountered:
Referencing this issue: #3624
Currently if you have Model and Submodel discriminating on the field "kind", and you do:
You end up with an instance of SubModel as the result. However, if you do:
Then doc is an instance of Model, not SubModel. While I understand the argument in the above issue that a polymorphic constructor is kind of confusing, it seems like this current situation is now even more confusing because one method of creating a new document will return SubModel, and the other will return Model.
In the docs, these two types of constructors are described as interchangeable and this difference in discriminator behaviour is not documented anywhere that I can find.
The text was updated successfully, but these errors were encountered: