I want to find document in a mongodb table using node js. I'm currently working with mongojs plugin.
Here's what I have problem with:
- I connect into DB.
- I get the current timestamp
- Every 10 seconds I want to print all elements added within this 10 seconds.
var timestamp = new Date().getTime();
console.log('timestamp to compare: ' + timestamp);
setInterval(function() {
var x = db.collection.find({'create_time' : {$gt : timestamp}}).toArray(function(err, entity) {
console.log(entity);
});
console.log('checking...')
timestamp = new Date().getTime();
console.log('timestamp to compare: ' + timestamp);
}, 10000);
Somehow I'm getting no results. Below you can see the command prompt output. http://s11.postimg.org/a8cnffedf/2015_03_11_1521.png
I'll apreciate any help. Thank you.