var mongoskin = require('mongoskin'),
db = null;
exports.getCollection = function (collectionName) {
if (!db) {
db = mongoskin.db("mongodb://server1:1301,server2:1301,server3:1301/tadTest?readPreference=secondaryPreferred",
{numberOfRetries: 1, retryMiliSeconds: 500, safe: true, native_parser: true},
{socketOptions: {timeout: 5000}});
}
return db.collection(collectionName);
}
setInterval(function(){
exports.getCollection('aaaa').insert({date: new Date()}, function(){
});
}, 10)
setInterval(function(){
exports.getCollection('aaaa').findOne({date: new Date()}, function(err, result){
if(err){
console.log(err, result);
}
});
}, 10)