How to display keys from DB in meteor


#1

How can I display the keys from MongoDB in HTML page. I do not want to display the values atached to the keys in UI.

I want to show all the keys but I am not aware how many keys are there in one document.

The DB is nested.

School:{
Student : {
“CATEGORY”: “Section1”,
“Team” :‘A’
},
Teacher : { “Experience” : 3,

          }

}

Is there a way to change Object.keys(someCollection.findOne()); //Returns array of strings
I want to extract keys Category, Team , Experience


#2

Not sure, but until someone with a better understanding replies, you could try using $returnKey.

Straight from the Meteor Manual:

Only return the index field or fields for the results of the query. If $returnKey is set to true and the query does not use an index to perform the read operation, the returned documents will not contain any fields. Use one of the following forms:

  db.collection.find( { <query> } )._addSpecial( "$returnKey", true )
  db.collection.find( { $query: { <query> }, $returnKey: true } )