Skip to content

Commit 2fa27cb

Browse files
authored
Feat: GET /group/:group_id serve details
Resolved: #171
1 parent 8353166 commit 2fa27cb

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

backend/controllers/groupController.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ module.exports = {
6363
try {
6464
const group_id = req.params.group_id;
6565

66-
const projection = {
67-
name: true, path: true,
68-
admins: true
69-
};
70-
const group = await groupService.read({ _id: group_id }, projection);
66+
const group = await groupService.read({ _id: group_id });
7167

7268
// Invalid group_id
7369
if(group === null) throw new NotFoundError(`NotFound: 검색결과가 없습니다.`);

backend/services/groupService.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@ module.exports = {
2323
return await Group.find(query, projection);
2424
},
2525

26-
read: async (query, projection = { name: true, path: true }) => {
26+
read: async (query, projection = {}) => {
2727
try {
28-
return await Group.findOne(query, projection);
28+
return await Group
29+
.findOne(query, projection)
30+
.populate([{
31+
path: 'admins',
32+
select: ['rank', 'name']
33+
}, {
34+
path: 'inspectors',
35+
select: ['rank', 'name']
36+
}]);
2937
} catch(err) {
3038
throw new RuntimeError(err.message);
3139
}

0 commit comments

Comments
 (0)