Hi I have three Schemas with this field's
var interactionSchema = new Schema({
pollee: { type: ObjectId, ref: 'Pollee' },
answers: { type: [ObjectId], ref: 'Answer', autopopulate: true },
status: type: String
});
var PolleeSchema = new Schema({
firstName: String,
lastName: String,
gender: String,
user: { type: ObjectId, ref: 'User', required: true },
interactions: { type: [ObjectId], ref: 'Interaction', autopopulate: true }
});
var userSchema = new Schema({
email: String,
pollee: { type: Schema.Types.ObjectId, ref: 'Pollee', autopopulate: true }
});
I need to realize a query in Pollee and pupulate fields from user and interactions, but from interactions I only need the status field, I dont need answers and other ObjectID arrays that contain the Interactions colection.
I made this Query
Pollee.find(req.body.filters)
.select('id age birthday country device_register gender municipality state parish user interactions.status')
.populate('user','email createdAt')
.exec(function(err,pollees){
//Other
}
//....
This return interactions array but status field is not returned. If I write only interactions on the select, return interactions with all fields from interactions.
I try this
Pollee.find(req.body.filters)
.select('id age birthday country device_register gender municipality state parish user')
.populate('user','email createdAt')
.populate('interactions', 'status')
.exec(function(err,pollees){
//Other
}
//....
This return nothing from interactions
I need only Status field from interactions.
The problem here is the interactions field from Pollee Schema, this field its a Array of ObjectsId, and this field its autopopulated from Schema. I want to select only the status field from interactions
Any idea?