I hope the heading describes my question right.
When I open /admin/liste, it should render two tables from MongoDB database. How can I render two or more collections?
app.get('/admin/liste', isLoggedIn, function(req, res) {
var List1 = mongoose.model('List1');
// var List2 = mongoose.model('List2');
List1.find(function (err, docs) {
res.render('admin/liste',{
firstlist : docs
});
});
/*List2.find(function (err, docs) {
res.render('admin/liste',{
seclist : docs
});
});*/
});
EDIT: I can't find any information to my problem in the reference, that this question is dublicate. I'm not using any Joins or something like that. I want to display two tables from the items which are in List1 and List2. The uncommented out code is working well, but this is only one table, so I have to combine those two, then render the page.
Hope anyone can help me, thank you.
Thank you for your answer. Meanwhile I found another solution for my problem:
I think we should first find items in List1 and store them in a variable. Then find items in List2 and render the ejs. Something like this:
You can do this by executing the second query within the callback of the first query so that both results are available for the
res.render
call: