Hi Folks,
How do you query a certain projected field in a collection?
i have this on my helpers:
var child = Enrollments.find( {
_id: selectedEnrollmentId.get()
}, {
fields: {
"childrenName": 1,
"children2Name": 1,
"children3Name": 1,
"children4Name": 1,
"children5Name": 1,
"children6Name": 1,
"children7Name": 1,
"children8Name": 1,
"children9Name": 1,
"children10Name": 1
}
} );
I don’t know what is going on, I have this simple query to check if I it has a data:
if ( child ) {
console.log( child.childrenName );
}
> undefined
without the condition:
console.log( child.childrenName );
> undefined
The field has a data that I’m querying.
What i was trying to do is to map all this 10 fields and pass it as a helper to a autoform select field.
I have this working code a week ago, the dropdown list is populating with the queried data:
listOfChildren = [
child.childrenName,
child.children2Name,
child.children3Name,
child.children4Name,
child.children5Name,
child.children6Name,
child.children7Name,
child.children8Name,
child.children9Name,
child.children10Name
];
return _.map( listOfChildren, function ( children ) {
return {
label: children,
value: children
};
} );
but last night i don’t know what is wrong with my code. Suddenly, it returned undefined
I’ve checked all my subscriptions and publications and it’s all fine.
Any help is much appreciated.
Thanks