MongoDB syntax to fetch single field

I’m using meteor with angular js
this query fetches everything from parties collection
parties: () => {
return Parties.find({});

I wanted to know how can i fetch single field in the same query?
if i do

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?

The format is a little different than pure mongo. You’re missing the fields specifier:

return Parties.find({}, {fields: {name: 1, _id: 0}});

i Tried this but its not working it gives me error
"You may not observe a cursor with {fields: {_id: 0}}"

Probably due to this:

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.

Thanks kako but its not working

i’m unable to figure out whats wrong with my code.