I have a Model structure as below in which the stage is retrieved from another model
var stageSchema = new Schema({
Name: String,
Stage: {
type: Schema.ObjectId,
ref: 'StageName',
}
}, {
collection: 'StageList'
});
I have written query to retrieve data using mongoose as shown below:
exports.findall = function(req, res) {
stage.find().populate({path:'Stage',select:'-_id'}).lean().exec(function(err, value1) {
res.send(value1);
});
};
It displays the result as shown below
[{_id:213465465465465, Name: "AAA", Stage: {Value: "Stage1"}},{_id:213465465465465, Name: "BBB", Stage: {Value: "Stage2"}}]
But I want the Stage to be in array format without the key "Value" as shown below:
[{_id:213465465465465, Name: "AAA", Stage: ["Stage1"]},{_id:213465465465465, Name: "BBB", Stage: ["Stage2"]}]
Please help to get through this problem. Thanks in advance.