Returning actions, items, and comments as seperate arrays.

This commit is contained in:
David Jay
2016-11-08 15:32:52 -05:00
parent fcd65c18fd
commit e8584b499b
2 changed files with 7 additions and 2 deletions
+2 -1
View File
@@ -47,9 +47,10 @@ ActionSchema.statics.getActionSummaries = function(item_ids) {
const actionSummaries = rawActions.reduce((actionObj, action) => {
if (!actionObj[action.item_id]) {
actionObj[action.item_id] = {
id: action.id,
type: action.action_type,
count: 1,
current_user: false //Corrent this later when we have authentication
current_user: false //Update this later when we have authentication
};
} else {
actionObj[action.item_id].count ++;
+5 -1
View File
@@ -17,7 +17,11 @@ router.get('/', (req, res, next) => {
Action.getActionSummaries(comments.map((comment) => comment.id))
]);
}).then(([comments, users, actions]) => {
res.json([...comments, ...users, ...actions]);
res.json({
comments,
users,
actions
});
}).catch(error => {
next(error);
});