猫鼬填充具有多个引用的数组

时间:2019-05-17 19:13:00

标签: mongoose mongoose-populate

MeetupSchema = new mongoose.Schema({

        meeting: {type: mongoose.Schema.Types.ObjectId, ref: 'Meeting'},
        eventYear: {
            type: Number
        },
        roles: [{
            _id: {type: mongoose.Schema.Types.ObjectId, ref: 'Roles', default: undefined},
            personID: {type: mongoose.Schema.Types.ObjectId, ref: 'Person', default: undefined}
        }],
        registrationDate: {
            type: Date,
            default:
            Date.now
        },
    },
    {
        versionKey: false
    });

如何用roles(一个对象数组,每个对象有两个引用)填充Meeting对象?

0 个答案:

没有答案