Answer the question
In order to leave comments, you need to log in
Why is mongoDB not executing the query again?
mongo.connect(config.get('mongodb:uri') + config.get('mongodb:dbName'), function(err, db) {
if (err) throw err;
var col = db.collection(config.get('mongodb:history'));
var mess = {};
col.find({_id: {$gt: midnight}}).forEach(function (res) {
if(res.priv.length == 0 && res.confirm.length == 0) {
mess = res.whoSend + ': ' + res.message;
arrayOfMessages.push(mess);
};
});
});
return arrayOfMessages;
Answer the question
In order to leave comments, you need to log in
// showTodaySimpleMessages.js
var config = require('config')
, mongo = require('mongodb').MongoClient;
var showTodaySimpleMessages = function () {
var arrayOfMessages = [];
var now = new Date();
var midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime().toString();
mongo.connect(config.get('mongodb:uri') + config.get('mongodb:dbName'), function(err, db) {
if (err) throw err;
var col = db.collection(config.get('mongodb:history'));
var mess = {};
col.find({_id: {$gt: midnight}}).forEach(function (res) {
if(res.priv.length == 0 && res.confirm.length == 0) {
mess = res.whoSend + ': ' + res.message;
arrayOfMessages.push(mess);
};
db.close();
});
});
return arrayOfMessages;
};
module.exports = showTodaySimpleMessages();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question