mahmoud mahmoud - 1 year ago 81
Javascript Question

How to access a specific field in Expressjs returned by mongodb collection.find method?

I'm Trying to access one field returned from mongodb collection.find method
, I can't do that and nothing is showing on the console.log

router.get('/buildings', function(req, res, next) {
var db = req.db;
var collection = db.get('buildings');

var x=docs[0].price;

Note: I'm using monk middle-ware not native mongodb


Answer Source

Check the error argument in the callback and your return argument is:


And not:


I'm surprised you don't get an undefined variable error.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download