1

I have multiple couchDB databases that contain multiple documents. I'm trying to populate 3 or more html selects with data from couchDB using nodeJS and nano client for couchDB. I'm trying to fetch all the documents inside a database an insert them in the select. Any ideas on how to achieve this? Preferably in a single request.

LE: I'm trying to make use of nano documentation using the list method: https://github.com/dscape/nano#dblistparams-callback

alice.list(function(err, body) {
  if (!err) {
    body.rows.forEach(function(doc) {
      console.log(doc);
    });
  }
});

Problem is with js being async I cannot gather all the information I need with list before the page gets rendered. At least I don't know of any way to achieve this and that is what I am trying to do. It would have been ok if I only needed one database but I need to query multiple ones.

I thought of doing multiple callbacks or using events package from nodejs but as I see it the code would become absolute nightmare.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Magarusu
  • 982
  • 10
  • 14
  • Your question is super broad ("How do I make a webapp?"). Can you show some code? – Eloims Apr 26 '16 at 11:39
  • @Eloims I've updated the question. I think it's still too broad but I need more of a guidline than actual code so that I know how I could tackle the problem. Please let me know if I could provide you with further details. Thank you. – Magarusu Apr 26 '16 at 11:47
  • Please show where you currently render the page – Eloims Apr 26 '16 at 13:01

0 Answers0