Using Mongodb, mongoose, nodejs, express....
I have a structure like this...
const EventSchema = new mongoose.Schema({
eventDate: {
type: Date
},
attendees: [
{
type: mongoose.Schema.ObjectId,
ref: 'Person'
}
],
staff: [
{
person: {
type: mongoose.Schema.ObjectId,
ref: 'User'
},
department: {
type: String,
enum: ['photography', 'data-entry', 'mgmt', 'other']
}
}
]
});
I know how to populate('attendees department'). That works fine and returns ALL data for both. But, because I'm dealing essentially with multiple populates, how do I SELECT the SPECIFIC fields that should be retrieved for attendees and department?