Category = collection.find({},{ name: true }).toArray();
console.log("Categories Found", Category);
Output:
Promise { [
{ name: 'Agriculture' },
{ name: 'engineer' }
] }
How do I get the value of name? (NOTE: Working in node JS)
collection.find({},{ name: true }).toArray().then(function(data){ console.log("Categories Found", data); })distinct()method which will give you the names in an array with a single call, as in this answer.