When a field in a mongoose schema contains a reference to some document in another data model/collection (as in the example below), is it possible for the ‘ref’ field to have more than one possible value?
const documentSchema = Schema({
_id: Schema.Types.ObjectId,
title: String,
date: Date,
references: [{ type: Schema.Types.ObjectId, ref: 'Person' }]
});
Suppose that instead of a model called ‘Person’, there were instead two or more possible models whose documents we might wish to reference (e.g., ‘Student’, ‘Professor’, ‘Administrator’…), depending on the case. Is there a way to specify that the data model of this reference could be ‘Student’, ‘Professor’, or ‘Administrator’, or is that simply not allowed?