Class: Connection

Connection

A class representing a single connection to a MongoDB server

new Connection(socket, options)

Creates a new Connection instance

Name Type Description
socket Socket

The socket this connection wraps

options Object optional

Optional settings

Name Type Default Description
host string optional

The host the socket is connected to

port number optional

The port used for the socket connection

keepAlive boolean true optional

TCP Connection keep alive enabled

keepAliveInitialDelay number 300000 optional

Initial delay before TCP keep alive enabled

connectionTimeout number 30000 optional

TCP Connection timeout setting

socketTimeout number 360000 optional

TCP Socket timeout setting

promoteLongs boolean optional

Convert Long values from the db into Numbers if they fit into 53 bits

promoteValues boolean optional

Promotes BSON values to native types where possible, set to false to only receive wrapper types.

promoteBuffers boolean optional

Promotes Binary BSON values to native Node Buffers.

Fires:

Methods

Destroy connection

isConnected(){boolean}

Is the connection connected

Return json object of connection

Return id of connection as a string

Unref this connection

Write to connection

Name Type Description
command Command

Command to write out need to implement toBin and toBinUnified

Events

The server connection closed, all pool connections closed

Type:

A server connect event, used to verify that the connection is up and running

Type:

The server connection caused an error, all pool connections closed

Type:

An event emitted each time the connection receives a parsed message from the wire

Type:

The driver experienced an invalid message, all pool connections closed

Type:

The server connection timed out, all pool connections closed

Type: