I am currently working with a script that I run through the mongo shell. The first query for posts works perfectly and I am able to receive the data object without any issues. Even when I print the date after running it through the convertDate function, the correct date is returned as expected. However, when it comes to the second postdata findOne function, none of the print statements seem to display anything. There isn't an error being shown, but there are no results found either, even though it should at least display 'no record'. Is there something that I might be overlooking here?
db.posts.find().forEach(function(data) {
var date = convertDate(data.created_at);
db.postdata.findOne({ company_id: data.company_id, date: date }, function(err, post){
if (err) { print('err' + err) }
if(post){
print('test' + post);
} else {
print('no record');
}
});
});