I am currently in the process of developing a polls application using express. The structure of my data is as follows:
var responseSchema = new mongoose.Schema({
responseText: String,
voters: []
})
module.exports = mongoose.model('Responses', responseSchema);
var pollsSchema = new mongoose.Schema({
question: String,
responses: [responseSchema],
})
When handling routes, I extract the ID from the parameters and generate an object that contains relevant information for the specific poll. However, this object includes a 'voters' array which stores SessionID's of users who have voted for each response. It is not ideal for this array to be included in the response.
My goal is to send back all details except for the 'voters' array. Is there a way to filter the http response so that it only contains the necessary data?