I'm publishing some data to a Meteor blaze template, I want to return specific fields but it's a complicated object with nested arrays/objects so I'm not sure how to do this
Here's what an example of the object I'm publishing would look like
{
"_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 <--------------
}
]
}
]
}
I'm publishing this with the following code:
return Assessments.find( {"name": "Exam Name"}, {fields: {name: 1, questions: 1}});
How can I modify that publication to exclude the key "correct" which I have highlighted with arrows?
Questions array > question object > answers array > answers object > correct key
If you are publishing all, but want to exclude one or more fields (seems like it), this should work:
return Assessments.find( {"name": "Exam Name"}, {fields: {
'questions.answers.correct': 0
}});