I'm making an app where users record the number of hours they slept, their eating habits, etc, which gets stored in a collection called Journal.
When the user clicks "stats", it triggers a function called find() which finds all the journal entires a user has submitted and console logs them.
This is what I have so far:
exports.stats = function(req, res) {
function find() {
Journal.findOne({'user': req.params.id}, 'sleep', function(err, journal){
if(err) throw err;
console.log(journal.sleep);
});
}
find();
}
In this example, I'm trying to console log the number of hours of sleep of a particular user, however, it only displays the number of hours of sleep of that session, and not ALL of the number of hours of sleep they have recorded