如何在猫鼬中为单个实体引用 2 个引用

问题描述

const roomsSchema = mongoose.Schema({
    hash: {
        type: String,required: true,unique: true
    },members: [{
        type: mongoose.Schema.ObjectId,ref: ['User','Staffs'],// line not working need help
    }],topic: {
        type: String,// for groups
    },messages: [{
        type: mongoose.Schema.ObjectId,ref: 'Message'
    }]
},{timestamps: true});

在上面的消息模式中,当我执行 .populate(members) 时,我有普通用户和员工,我只从用户集合中获取引用,而不是从员工集合中获取引用。如果有人克服了它,请建议我

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)