Trying to display data from mongodb database in node.js app -


server.get('/', function(req, res) {     counter.find({}, function(err, result) {         if (!(err)) {             res.render('index', {'lol' : result});         }     }); }); 

i'm trying app display contents of whole database , came with. counter mongoose model. database contains items inserted prior execution of program , 1 item inserted in app itself.

something iffy conceptually me (i'm new node), think render() being executed before find() why i'm not getting result, can't think of solution. or push in right direction appreciated. :)

what view code?

your implementation correct, should try debug.

server.get('/', function(req, res) {   counter.find({}, function(err, result) {     if (!(err)) {         console.log('debug: ' + json.stringify(result) );         res.render('index', {lol : result});     }   }); }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -