I have a collection which has a possibility of null values. Let’s say it’s called Student
. If a student does not have an advisor, the field Student.advisorId
is null. If a user does not have a login, their Student.userId
is null. Same with, for example, Student.profileImageId
This is giving me a problem with ugly publications
Meteor.publish('student', function (studentId) {
return Students.find({ _id: patientId }).map(function(doc) {
var cursors = [];
if(!_.isNull(doc.profileImageId) {
cursors.push(Thumbnails.find({ _id: doc.profileImageId }));
}
if(!_.isNull(doc.advisorId) {
cursors.push(Advisors.find({ _id: doc.advisorId }));
});
// ... etc.
return cursors;
});
});
What is a good way to handle this?