I’m using meteor with angular js
this query fetches everything from parties collection
$scope.helpers({
parties: () => {
return Parties.find({});
}
I wanted to know how can i fetch single field in the same query?
if i do
$scope.helpers({
parties: () => {
return Parties.find({},{name:1,_id:0});
}
it shows the result well on mongoDb terminal but when i execute the same query in application i’m unable to o the same
how can i do that?
With one exception, it is not possible to mix inclusion and exclusion styles: the keys must either be all 1 or all 0. The exception is that you may specify _id: 0 in an inclusion specifier, which will leave _id out of the result object as well. However, such field specifiers can not be used with observeChanges, observe, cursors returned from a publish function, or cursors used in {{#each}} in a template. They may be used with fetch, findOne, forEach, and map.
Would leaving _id alone work? Like:
return Parties.find({}, {fields: {name: 1}});
Not sure what your use case is, but if it does work, then maybe you can just remove the id when rendering your view.