1

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"?

Swirls
  • 45
  • 6

0 Answers0