findOne - returning the whole object, not just a field

I have the following code:

console.log(FlavoursList.findOne(selectedFlavour, {name: 1}));

It returns the following:

Object {_id: "EYvEHWMXuRMvXWKLW", name: "chocolate", votes: 42}

I want it to return just the name! I thought that the second argument limited the scope to return…

console.log(FlavoursList.findOne(selectedFlavour, {fields: {name: 1}}));

The following comes back:

Object {name: "chocolate", _id: "EYvEHWMXuRMvXWKLW"}

How do I then just extract the value of “name”?

FlavoursList.findOne(selectedFlavour, {fields: {name: 1}}).name

1 Like

That did it. Thanks!