I need to show all fields name on the UI from MongoDB collection. I am using NodeJS+Mongoose. Can anyone help me on this?
-Krishna
I need to show all fields name on the UI from MongoDB collection. I am using NodeJS+Mongoose. Can anyone help me on this?
-Krishna
There is no native function or way to list all fields of a collection because MongoDB is "schemaless". You need to iterate all the documents from the collection and get all the field names. Or simply get the field names from the results of the query you are displaying (like Robomongo).
You can try a MapReduce like the suggest in this post.
I don't recommend to do this very often because is a very expensive operation.