Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// Save the db reference
self.db = db;
// Log info about mongodb connection
if(self.logger.isInfo()) self.logger.info(f('correctly connected to MongoDB topology for client connection %s:%s'
, remoteAddress
, remotePort));
// Unpack the mongodb-core
if(self.db.serverConfig instanceof m.Server) {
self.topology = self.db.serverConfig.s.server;
} else if(self.db.serverConfig instanceof m.ReplSet) {
self.topology = self.db.serverConfig.s.replset;
} else if(this.db.serverConfig instanceof m.Mongos) {
self.topology = self.db.serverConfig.s.mongos;
}
// Connection closed by peer
connection.on('end', function() {
if(self.logger.isInfo()) self.logger.info(f('connection closed from %s:%s'
, remoteAddress
, remotePort));
// Shut down db connection
db.close();
});
// Data handler
connection.on('data', dataHandler(self));
// Data handler
/*!
* Module dependencies.
*/
var MongooseConnection = require('../../connection')
, mongo = require('mongodb')
, Db = mongo.Db
, Server = mongo.Server
, Mongos = mongo.Mongos
, STATES = require('../../connectionstate')
, ReplSetServers = mongo.ReplSetServers;
/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
*
* @inherits Connection
* @api private
*/
function NativeConnection() {
MongooseConnection.apply(this, arguments);
this._listening = false;
};
/**
/*!
* Module dependencies.
*/
var MongooseConnection = require('../../connection'),
mongo = require('mongodb'),
Db = mongo.Db,
Server = mongo.Server,
Mongos = mongo.Mongos,
STATES = require('../../connectionstate'),
ReplSetServers = mongo.ReplSet;
/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
*
* @inherits Connection
* @api private
*/
function NativeConnection() {
MongooseConnection.apply(this, arguments);
this._listening = false;
}
/**
/*!
* Module dependencies.
*/
var MongooseConnection = require('../../connection');
var mongo = require('mongodb');
var Db = mongo.Db;
var Server = mongo.Server;
var Mongos = mongo.Mongos;
var STATES = require('../../connectionstate');
var ReplSetServers = mongo.ReplSet;
var DisconnectedError = require('../../error/disconnected');
/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
*
* @inherits Connection
* @api private
*/
function NativeConnection() {
MongooseConnection.apply(this, arguments);
this._listening = false;
}
/*!
* Module dependencies.
*/
var MongooseConnection = require('../../connection')
, mongo = require('mongodb')
, Db = mongo.Db
, Server = mongo.Server
, Mongos = mongo.Mongos
, STATES = require('../../connectionstate')
, ReplSetServers = mongo.ReplSet
, utils = require('../../utils');
/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
*
* @inherits Connection
* @api private
*/
function NativeConnection() {
MongooseConnection.apply(this, arguments);
this._listening = false;
};
/*!
* Module dependencies.
*/
var MongooseConnection = require('../../connection');
var mongo = require('mongodb');
var Db = mongo.Db;
var Server = mongo.Server;
var Mongos = mongo.Mongos;
var STATES = require('../../connectionstate');
var ReplSetServers = mongo.ReplSet;
var DisconnectedError = require('../../error/disconnected');
/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
*
* @inherits Connection
* @api private
*/
function NativeConnection() {
MongooseConnection.apply(this, arguments);
this._listening = false;
}
/*!
* Module dependencies.
*/
var MongooseConnection = require('../../connection');
var mongo = require('mongodb');
var Db = mongo.Db;
var Server = mongo.Server;
var Mongos = mongo.Mongos;
var STATES = require('../../connectionstate');
var ReplSetServers = mongo.ReplSet;
var DisconnectedError = require('../../error/disconnected');
/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
*
* @inherits Connection
* @api private
*/
function NativeConnection() {
MongooseConnection.apply(this, arguments);
this._listening = false;
}
/*!
* Module dependencies.
*/
var MongooseConnection = require('../../connection')
, mongo = require('mongodb')
, Db = mongo.Db
, Server = mongo.Server
, Mongos = mongo.Mongos
, STATES = require('../../connectionstate')
, ReplSetServers = mongo.ReplSetServers
, utils = require('../../utils');
/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
*
* @inherits Connection
* @api private
*/
function NativeConnection() {
MongooseConnection.apply(this, arguments);
this._listening = false;
};
/*!
* Module dependencies.
*/
var MongooseConnection = require('../../connection'),
mongo = require('mongodb'),
Db = mongo.Db,
Server = mongo.Server,
Mongos = mongo.Mongos,
STATES = require('../../connectionstate'),
ReplSetServers = mongo.ReplSet;
/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
*
* @inherits Connection
* @api private
*/
function NativeConnection() {
MongooseConnection.apply(this, arguments);
this._listening = false;
}
/**
/*!
* Module dependencies.
*/
var MongooseConnection = require('../../connection');
var mongo = require('mongodb');
var Db = mongo.Db;
var Server = mongo.Server;
var Mongos = mongo.Mongos;
var STATES = require('../../connectionstate');
var ReplSetServers = mongo.ReplSet;
var DisconnectedError = require('../../error/disconnected');
/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
*
* @inherits Connection
* @api private
*/
function NativeConnection() {
MongooseConnection.apply(this, arguments);
this._listening = false;
}