When I try to change any part of the data returned by a Mongoose Query it has no effect.
I was trying to figure this out for about 2 hours yesterday, with all kinds of _.clone()
s, using temporary storage variables, etc. Finally, just when I though I was going crazy, I found a solution. So I figured somebody in the future (fyuuuture!) might have the save issue.
Survey.findById(req.params.id, function(err, data){
var len = data.survey_questions.length;
var counter = 0;
_.each(data.survey_questions, function(sq){
Question.findById(sq.question, function(err, q){
sq.question = q; //has no effect
if(++counter == len) {
res.send(data);
}
});
});
});
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…