我要发布一些数据到Meteor blaze模板,我想返回特定的字段但它是一个复杂的对象嵌套数组/对象所以我不确定如何做到这一点
下面是我要发布的对象的一个示例
{
"_id": "q9i6qAZmKcf6MCPE2",
"name": "Exam Name",
"questions": [
{
"number": 1,
"question": "Question 1",
"multipleTrue": false,
"answers": [
{
"letter": "a",
"answer": "Blah Blah",
"correct": false <--------------
},
{
"letter": "b",
"answer": "Blah Blah",
"correct": true <--------------
}
]
},
{
"number": 2,
"question": "Question 2",
"multipleTrue": false,
"answers": [
{
"letter": "a",
"answer": "Blah Blah",
"correct": true <--------------
},
{
"letter": "b",
"answer": "Blah Blah",
"correct": true <--------------
}
]
}
]
}
我用下面的代码发布这个:
return Assessments.find( {"name": "Exam Name"}, {fields: {name: 1, questions: 1}});
如何修改该发布以排除我用箭头突出显示的键"正确"?
问题数组>问题对象>答案数组>答案对象>正确键
如果您要发布所有字段,但想要排除一个或多个字段(看起来是这样),这应该可以工作:
return Assessments.find( {"name": "Exam Name"}, {fields: {
'questions.answers.correct': 0
}});