Added createdAt and updatedAt to queries
This commit is contained in:
@@ -28,6 +28,8 @@ GET /news/archive/:id
|
|||||||
"author": author, //author of the aricle
|
"author": author, //author of the aricle
|
||||||
"body": body, //body of the article
|
"body": body, //body of the article
|
||||||
"edits": edits //number of times this article has been edited
|
"edits": edits //number of times this article has been edited
|
||||||
|
"createdAt": createdAt //time created
|
||||||
|
"updatedAt": updatedAt //time updated
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
@@ -44,6 +46,9 @@ GET /news/archive/titles/:id
|
|||||||
"index": index, //absolute index of the result
|
"index": index, //absolute index of the result
|
||||||
"title": title, //title of the article
|
"title": title, //title of the article
|
||||||
"author": author //author of the article
|
"author": author //author of the article
|
||||||
|
"edits": edits //number of times this article has been edited
|
||||||
|
"createdAt": createdAt //time created
|
||||||
|
"updatedAt": updatedAt //time updated
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const query = (ascending, titlesOnly) => async (req, res) => {
|
|||||||
if (req.params.id && typeof(parseInt(req.params.id)) === 'number') {
|
if (req.params.id && typeof(parseInt(req.params.id)) === 'number') {
|
||||||
const result = await articles.findOne({
|
const result = await articles.findOne({
|
||||||
attributes: [
|
attributes: [
|
||||||
'index', 'title', 'author', ...(!titlesOnly ? ['body', 'edits'] : [])
|
'index', 'title', 'author', 'edits', 'createdAt', 'updatedAt', ...(!titlesOnly ? ['body'] : [])
|
||||||
],
|
],
|
||||||
where: {
|
where: {
|
||||||
index: {
|
index: {
|
||||||
@@ -24,7 +24,7 @@ const query = (ascending, titlesOnly) => async (req, res) => {
|
|||||||
else {
|
else {
|
||||||
const result = await articles.findAndCountAll({
|
const result = await articles.findAndCountAll({
|
||||||
attributes: [
|
attributes: [
|
||||||
'index', 'title', 'author', ...(!titlesOnly ? ['body', 'edits'] : [])
|
'index', 'title', 'author', 'edits', 'createdAt', 'updatedAt', ...(!titlesOnly ? ['body'] : [])
|
||||||
],
|
],
|
||||||
order: [
|
order: [
|
||||||
['index', ascending ? 'ASC' : 'DESC']
|
['index', ascending ? 'ASC' : 'DESC']
|
||||||
|
|||||||
Reference in New Issue
Block a user