find
returns a cursor, which is an object that contains the results of your search (somewhat like an array of results). It does it this way since find
can get more than just one result, depending on the selector you passed.
It has a forEach
similar to JS that accepts a function and receives the document, the index, and the cursor as parameters.
Values.find({name: "value"}).forEach(function(doc,index,cursor){
console.log(doc.id);
});
Visually, a result of find
in your case looks something like:
[
{id: SOME_RANDOM_NUMBER, name: "value"},
{id: SOME_RANDOM_NUMBER, name: "value"},
{id: SOME_RANDOM_NUMBER, name: "value"},
{id: SOME_RANDOM_NUMBER, name: "value"},
]