| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/readjs/node_modules/mongodb-core/ |
Upload File : |
var Server = require('./lib/topologies/server');
// Attempt to connect
var server = new Server({
host: 'localhost', port: 27017, socketTimeout: 500
});
// function executeCursors(_server, cb) {
// var count = 100;
//
// for(var i = 0; i < 100; i++) {
// // Execute the write
// var cursor = _server.cursor('test.test', {
// find: 'test.test'
// , query: {a:1}
// }, {readPreference: new ReadPreference('secondary')});
//
// // Get the first document
// cursor.next(function(err, doc) {
// count = count - 1;
// if(err) console.dir(err)
// if(count == 0) return cb();
// });
// }
// }
server.on('connect', function(_server) {
setInterval(function() {
_server.insert('test.test', [{a:1}], function(err, r) {
console.log("insert")
});
}, 1000)
// console.log("---------------------------------- 0")
// // Attempt authentication
// _server.auth('scram-sha-1', 'admin', 'root', 'root', function(err, r) {
// console.log("---------------------------------- 1")
// // console.dir(err)
// // console.dir(r)
//
// _server.insert('test.test', [{a:1}], function(err, r) {
// console.log("---------------------------------- 2")
// console.dir(err)
// if(r)console.dir(r.result)
// var name = null;
//
// _server.on('joined', function(_t, _server) {
// if(name == _server.name) {
// console.log("=========== joined :: " + _t + " :: " + _server.name)
// executeCursors(_server, function() {
// });
// }
// })
//
// // var s = _server.s.replicaSetState.secondaries[0];
// // s.destroy({emitClose:true});
// executeCursors(_server, function() {
// console.log("============== 0")
// // Attempt to force a server reconnect
// var s = _server.s.replicaSetState.secondaries[0];
// name = s.name;
// s.destroy({emitClose:true});
// // console.log("============== 1")
//
// // _server.destroy();
// // test.done();
// });
// });
// });
});
server.connect();