Skip to content

Instantly share code, notes, and snippets.

@anthonytxie
Last active April 10, 2018 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonytxie/a4970bebd29d8aea26b7016e2525b529 to your computer and use it in GitHub Desktop.
Save anthonytxie/a4970bebd29d8aea26b7016e2525b529 to your computer and use it in GitHub Desktop.
Comment.find({})
.sort({ commentDate: 1 })
.then(comments => {
let commentsObject = {};
comments.forEach(comment => {
let commentDate = moment(comment.commentDate).startOf("day");
if (!commentsObject[commentDate]) {
commentsObject[commentDate] = 1;
} else {
commentsObject[commentDate] += 1;
}
});
fs.writeFile(
"hodlComments.json",
JSON.stringify(commentsObject),
"utf8",
() => {
console.log("done");
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment