Compare commits

...

3 Commits

Author SHA1 Message Date
Primakov Alexandr Alexandrovich
8a2afc3f1b 1.1.1 2025-01-19 21:05:16 +03:00
Primakov Alexandr Alexandrovich
d824844ae5 populate author of comments 2025-01-19 21:05:08 +03:00
Primakov Alexandr Alexandrovich
f95a26acbb todo-app: get item by id 2025-01-19 20:44:26 +03:00
3 changed files with 5 additions and 5 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "multi-stub",
"version": "1.1.0",
"version": "1.1.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "multi-stub",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",
"dependencies": {
"axios": "^1.7.9",

View File

@@ -1,6 +1,6 @@
{
"name": "multi-stub",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"main": "index.js",
"scripts": {

View File

@@ -42,12 +42,12 @@ 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')))
}
res.send(getAnswer(null, item.comments))
res.send(getAnswer(null, item))
})
module.exports = router