mongoose基于属性的dynamic引用

我想有一个基于模式中的另一个属性的dynamic引用?

我有以下模式,位置可以由个人或组织控制(例如,办公大楼由公司控制,其中作为本地商店由所有者控制)。

// Has other fields - brief for simplicity. var personSchema = new Schema({ _id: {type: String, required: true}, name: {type: String, required: true}, }); var PersonData = mongoose.model('PersonData', personSchema ); // Has other fields - brief for simplicity. var organizationSchema = new Schema({ _id: {type: String, required: true}, name: {type: String, required: true}, members: [{ type: String, ref: 'PersonData'}] }); var OrganizationData = mongoose.model('OrganizationData', organizationSchema ); var locationSchema = new Schema({ _id: {type: String, required: true}, name: {type: String, required: true}, controlledBy:{ type: {String, enum: [ 'Organization', 'Individual']}, controller: { type: String, ref: 'PersonData' or 'OrganizationData'} } }); 

我想一个select是将两个字段放在“controlledBy”中,但不确定这是否是最好的方法?

 controlledBy:{ type: {String, enum: [ 'Organization', 'Individual']}, individual: { type: String, ref: 'PersonData' }, organization: { type: String, ref: 'OrganizationData'} } 

有了上面的我想我可以放下这个types呢?