I have a database in mongodb and I’m connecting to it through NodeJS and mongodb native driver. I’m trying to write a javascript code to print in the browser the information retrieved from the database through db.foo.find() operation.
I am currently able to print the value part of the json data. However, i need to print the key part as well.
Example : json data { key1:v1, key2:v2 ….}
i need a way to access the key1 and key2 values through javascript code without knowing them prehand??
1 Answer