Feature: returns a list of entries when creating, editing or deleting an entry

This commit is contained in:
2015-08-14 14:35:00 +00:00
parent ffbc4f4980
commit 399a8717d3
3 changed files with 72 additions and 16 deletions

View File

@@ -143,8 +143,19 @@ module.exports = {
return Handler.errorHandler(errors, 400, response);
}
response.status(201).json(entry);
})
Entry
.find({account_id: account.id})
.sort({date: -1})
.exec(function(errors, entries) {
if( errors ) {
return Handler.errorHandler(errors, 500, response);
}
response.status(201).json({
entry: entry,
entries: entries
});
});
});
});
},
@@ -177,7 +188,18 @@ module.exports = {
return Handler.errorHandler(errors, 400, response );
}
return response.json(entry);
Entry
.find({account_id: account.id})
.sort({date: -1})
.exec(function(errors, entries) {
if( errors ) {
return Handler.errorHandler(errors, 500, response);
}
response.status(200).json({
entry: entry,
entries: entries
});
});
});
});
});
@@ -203,7 +225,18 @@ module.exports = {
return Handler.errorHandler(errors, 500, response);
}
return response.status(204).end();
Entry
.find({account_id: account.id})
.sort({date: -1})
.exec(function(errors, entries) {
if( errors ) {
return Handler.errorHandler(errors, 500, response);
}
response.status(204).json({
entry: entry,
entries: entries
});
});
});
});
});