Last active
April 10, 2018 13:43
-
-
Save anthonytxie/a4970bebd29d8aea26b7016e2525b529 to your computer and use it in GitHub Desktop.
This file contains 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
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