I'm a beginner in both MongoDB and node.js. Actually, I'm trying to get the names of a particular document but I wonder how to do that. Let me elaborate in detail : if "a" is a collection which contains document named "student" and "student" contains fields like
{
"_id: "student",
"name": "alex",
"roll": "3",
"age":"13"
}
then how to get the field names in this ["name","roll","age"]
format
By trying this:
db.collection("user").find({ "_id": "student" }).toArray(function(err, result) {
console.log(result)
})
is giving all the fields with their values.