1

Currently using node.js along with mongoose and express. I have two collections in my MongoDB and I can successfully retrieve data like this:

ActivityList.prototype = {
  showActivities: function(req, res) {
    point.find({}, function foundPoints(err, items) {
      res.render('index2',{title: 'Credits' , points: items})
    });
}

These data can be treated in my index.jade like this:

form(action="/asdad", method="post")
   select(name = "item[point]")
   each point in points
    option(value='onlytesting') #{point.Activity}
  input(type="submit", value="Update tasks")

As you can see I am using this to fill a drop down menu.. My issue is that i want to fill multiple drop down menus with data from other collections also.

The page is supposed to be my index.jade, such that a user is presented with multiple drop down menus which will be pulled directly from MongoDB.

My app.js calls:

app.get('/', activityList.showActivities.bind(activityList));

That works just fine, but I want to be able to fetch other data also with the "same" get..

Does anyone know how this can be accomplished? Thanks for any tips

Are
  • 179
  • 1
  • 3
  • 16
  • 2
    I think your best bet would be to coordinated those queries using a module like [async](https://github.com/caolan/async), and render the template once all queries have returned their results. – robertklep May 17 '13 at 12:13
  • 1
    Possible duplicate of [How to return Mongoose results from the find method?](http://stackoverflow.com/questions/6180896/how-to-return-mongoose-results-from-the-find-method) – Alexis Tyler Mar 20 '16 at 05:57
  • Found a solution to this, used tips from "The easy way" by trollix on this post. http://stackoverflow.com/questions/6180896/how-to-return-mongoose-results-from-the-find-method – Are May 22 '13 at 13:02

0 Answers0