Compare commits

...

2 Commits

Author SHA1 Message Date
bbc315e270 Merge pull request 'get count by modelname' (#38) from feature/check-jenkins into master
Reviewed-on: #38
2024-10-16 11:57:57 +03:00
Primakov Alexandr Alexandrovich
fbb5d26c8f get count by modelname 2024-10-16 11:55:42 +03:00

View File

@ -10,14 +10,23 @@ const folderPath = path.resolve(__dirname, './routers')
const folders = fs.readdirSync(folderPath)
router.get('/', async (req, res) => {
res.send(`
res.send(`
<h1>multy stub is working v${pkg.version}</h1>
<ul>
${folders.map((f) => `<li>${f}</li>`).join('')}
</ul>
<h2>models</h2>
<ul>${(await mongoose.modelNames()).map((name) => `<li>${name}</li>`)}</ul>
<ul>${
(await Promise.all(
(
await mongoose.modelNames()).map(async (name) => {
const count = await mongoose.model(name).countDocuments()
return `<li>${name} - ${count}</li>`
}
)
)).map(t => t).join(' ')
}</ul>
`)
})