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.