Created
April 21, 2021 20:45
-
-
Save smpnjn/d4586cea5b2859e1d68a81d4a8dbd3b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let root = { | |
title: async () => { | |
let allArticles = []; | |
// Query our mongoDB | |
let articles = await Article.find(); | |
// Return data in appropriate format | |
articles.forEach(function(item) { | |
if(typeof item.title === "string") { | |
allArticles.push(item.title); | |
} | |
}); | |
return allArticles; | |
}, | |
articleAge: async () => { | |
// Repeat | |
let allDates = []; | |
let articles = await Article.find(); | |
articles.forEach(function(item) { | |
if(typeof item.date === "number") { | |
allDates.push(item.date); | |
} | |
}); | |
return allDates; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment