mongoose - Cast 'parent' type to 'child' type based on discriminator

Viewed 140

So I have a base schema called Base and using Base.discriminator(...) I have created sub-types called ChildA and ChildB.

If I do Base.find({}) I will get all documents, is it possible to cast an instance of Base to ChildA or ChildB depending on the discriminator value?

0 Answers
Related