I have a two collection one is Category and the other is Blog while looping out the category, i want to get the numbers of post such category have in my Blog collection, using the category field in blog collection I was able to have this output on console with the code below, but how do I render it in ejs to have this result beneath?
Business 4
Sport 2
Religion 1
But how do I render it in ejs to look like this
I did this in my routes with the code below
app.get('/articles/play', async (req, res) => {
const category = await catModel.find()
category.forEach(async cat => {
// console.log(cat.catname)
const countIt = await blogModel.countDocuments({category: cat.catname})
console.log(cat.catname, countIt)
})
})