Issue
This Content is from Stack Overflow. Question asked by Swirls
I’m trying to get data from two separate collections and sending them over to .hbs
I understand how to get the data from one collection, but I’m having trouble with the second one.
const KillLogs = require('../models/MurderLogs');
const RobberyLogs = require('../models/RobberyLogs');
//It gets data from KillLogs and it works perfectly fine, but I don't know how to get data from RobberyLogs as well and save it to "logsData" so it can be transferred over to .hbs, I am not sure if there is another way of doing this but this is my way, please feel free to correct me or give me advices
router.get('/', isLoggedIn, async (req, res) => {
let logsResult = await KillLogs.find({}).lean().exec((err, logsData) => {
if(logsData) {
res.render("index", { title: "Home", data:logsData});
}
})
});
As you can see in the code it gets data from “KillLogs” but how can I get data from “KillLogs and RobberyLogs”?
Solution
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.
This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.