0
votes

Are there ways to make a property on a Mongoose Model with a polymorphic ObjectId reference and validate reference type is allowed?

I am trying to make a 'Contract' model with properties specifying multiple parties ('Buyer' and 'Seller' objects). I also have a property on the Contract model to capture the contract 'Proposer', which should be a reference to either a Buyer or Seller object.

Can this be done with vanilla Mongoose or plugins, or should I look to use a Mixed object reference and add my own custom validation logic to this?

Thanks for any advice!