populate author of comments

This commit is contained in:
Primakov Alexandr Alexandrovich 2025-01-19 21:05:08 +03:00
parent f95a26acbb
commit d824844ae5

View File

@ -42,7 +42,7 @@ router.get('/:todoId/:itemId', async (req, res) => {
return res.send(getAnswer(new Error('no such todo')))
}
const item = await ItemModel.findById(itemId).populate('comments').exec()
const item = await ItemModel.findById(itemId).populate({ path: 'comments', populate: { path: 'author' } }).exec()
if (!item) {
return res.send(getAnswer(new Error('no such item')))
}