findOne - returning the whole object, not just a field


#1

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…


#2

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


#3

The following comes back:

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

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


#4

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


#5

That did it. Thanks!