Express-Handlebars list all collections in database and for each collection display data

Viewed 16

I'm trying to make something like this, "1" gets a collection from the database and when you press on that "Name of Collection" it will update "2", the website won't get reloaded, it should just display data on the "2" field.

I really don't know how to make this haha, I might have given myself a difficult task, any advice is welcome

{{#each collection}}
<a href="" class="d-flex">
   <i class="my-auto fa-regular fa-copy"></i>
    <span class="ms-2"> {{collection_name}}</span> 
</a>
{{/each}}
router.get('/', isLoggedIn, async (req, res) => {
    let logsResult = await KillLogs.find({}).lean().exec((err, logsData) => {
        res.render('index', { title: 'Home', data: logsData });
    })
});

My current code does not get all of the collections, it just goes thru one collection and sends that data to handlebars.

The HTML code is just a snippet to understand what I'm trying to achieve.enter image description here

0 Answers
Related