Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface MongoConnectionOptions

MongoDB specific connection options. Synced with http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html

Hierarchy

Index

Properties

Optional acceptableLatencyMS

acceptableLatencyMS: number

Sets the range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms). Default: 15

Optional appname

appname: string

The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections

Optional authMechanism

authMechanism: string

Sets the authentication mechanism that MongoDB will use to authenticate the connection

Optional authSource

authSource: string

If the database authentication is dependent on another databaseName.

Optional autoReconnect

autoReconnect: boolean

Reconnect on error. Default: true

Optional auto_reconnect

auto_reconnect: boolean

Enable auto reconnecting for single server instances. Default: true

Optional bufferMaxEntries

bufferMaxEntries: number

Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited.

Optional cache

cache: boolean | object

Allows to setup cache options.

Optional checkServerIdentity

checkServerIdentity: boolean | Function

Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function Default: true

Optional cli

cli: object

CLI settings.

Type declaration

  • Optional entitiesDir?: string

    Directory where entities should be created by default.

  • Optional migrationsDir?: string

    Directory where migrations should be created by default.

  • Optional subscribersDir?: string

    Directory where subscribers should be created by default.

Optional compression

compression: any

Type of compression to use: snappy or zlib

Optional connectTimeoutMS

connectTimeoutMS: number

TCP Connection timeout setting. Default: 30000

Optional connectWithNoPrimary

connectWithNoPrimary: boolean

Sets if the driver should connect even if no primary is available. Default: false

Optional database

database: string

Database name to connect to.

Optional domainsEnabled

domainsEnabled: boolean

Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. Default: false

Optional dropSchema

dropSchema: boolean

Drops the schema each time connection is being established. Be careful with this option and don't use this in production - otherwise you'll lose all production data. This option is useful during debug and development.

Optional entities

entities: (string | Function | EntitySchema<any>)[]

Entities to be loaded for this connection. Accepts both entity classes and directories where from entities need to be loaded. Directories support glob patterns.

Optional entityPrefix

entityPrefix: string

Prefix to use on all tables (collections) of this connection in the database.

Optional extra

extra: any

Extra connection options to be passed to the underlying driver.

todo: deprecate this and move all database-specific types into hts own connection options object.

Optional family

family: number

Version of IP stack. Can be 4, 6. If undefined, will attempt to connect with IPv6, and will fall back to IPv4 on failure

Optional forceServerObjectId

forceServerObjectId: boolean

Force server to assign _id values instead of driver. Default: false

Optional fsync

fsync: boolean

Specify a file sync write concern. Default: false

Optional ha

ha: boolean

Control if high availability monitoring runs for Replicaset or Mongos proxies. Default true

Optional haInterval

haInterval: number

The High availability period for replicaset inquiry. Default: 10000

Optional host

host: string

Database host.

Optional ignoreUndefined

ignoreUndefined: boolean

Specify if the BSON serializer should ignore undefined fields. Default: false

Optional j

j: boolean

Specify a journal write concern. Default: false

Optional keepAlive

keepAlive: number

The number of milliseconds to wait before initiating keepAlive on the TCP socket. Default: 30000

Optional logger

logger: "advanced-console" | "simple-console" | "file" | "debug" | Logger

Logger instance used to log queries and events in the ORM.

Optional loggerLevel

loggerLevel: "error" | "warn" | "info" | "debug"

Specify the log level used by the driver logger (error/warn/info/debug).

Optional logging

logging: LoggerOptions

Logging options.

Optional maxQueryExecutionTime

maxQueryExecutionTime: number

Maximum number of milliseconds query should be executed before logger log a warning.

Optional maxStalenessSeconds

maxStalenessSeconds: number

Specify a maxStalenessSeconds value for secondary reads, minimum is 90 seconds

Optional migrations

migrations: (string | Function)[]

Migrations to be loaded for this connection. Accepts both migration classes and directories where from migrations need to be loaded. Directories support glob patterns.

Optional migrationsRun

migrationsRun: boolean

Indicates if migrations should be auto run on every application launch. Alternative to it, you can use CLI and run migrations:run command.

Optional migrationsTableName

migrationsTableName: string

Migrations table name, in case of different name from "migrations". Accepts single string name.

Optional minSize

minSize: number

If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections

Optional monitorCommands

monitorCommands: boolean

Enable command monitoring for this client. Default: false

Optional name

name: string

Connection name. If connection name is not given then it will be called "default". Different connections must have different names.

Optional namingStrategy

namingStrategy: NamingStrategyInterface

Naming strategy to be used to name tables and columns in the database.

Optional noDelay

noDelay: boolean

TCP Socket NoDelay option. Default: true

Optional numberOfRetries

numberOfRetries: number

The number of retries for a tailable cursor. Default: 5

Optional password

password: string

Database password.

Optional pkFactory

pkFactory: any

A primary key factory object for generation of custom _id keys.

Optional poolSize

poolSize: number

Set the maximum poolSize for each individual server or proxy connection.

Optional port

port: number

Database host port.

Optional promiseLibrary

promiseLibrary: any

A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible.

Optional promoteBuffers

promoteBuffers: boolean

Promotes Binary BSON values to native Node Buffers. Default: false

Optional promoteLongs

promoteLongs: boolean

Promotes Long values to number if they fit inside the 53 bits resolution. Default: true

Optional promoteValues

promoteValues: boolean

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

Optional raw

raw: boolean

Return document results as raw BSON buffers. Default: false

Optional readConcern

readConcern: any

Specify a read concern for the collection. (only MongoDB 3.2 or higher supported).

Optional readPreference

readPreference: ReadPreference | string

The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).

Optional readPreferenceTags

readPreferenceTags: any[]

Read preference tags

Optional reconnectInterval

reconnectInterval: number

Server will wait #milliseconds between retries. Default 1000

Optional reconnectTries

reconnectTries: number

Server attempt to reconnect #times. Default 30

Optional replicaSet

replicaSet: string

The name of the replicaset to connect to

Optional secondaryAcceptableLatencyMS

secondaryAcceptableLatencyMS: number

Sets the range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms). Default: 15

Optional serializeFunctions

serializeFunctions: boolean

Serialize functions on any object. Default: false

Optional socketTimeoutMS

socketTimeoutMS: number

TCP Socket timeout setting. Default: 360000

Optional ssl

ssl: boolean

Use ssl connection (needs to have a mongod server with ssl support). Default: false

Optional sslCA

sslCA: string[] | Buffer[]

Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher).

Optional sslCRL

sslCRL: string | Buffer

SSL Certificate revocation list binary buffer (needs to have a mongod server with ssl support, 2.4 or higher)

Optional sslCert

sslCert: string | Buffer

String or buffer containing the certificate we wish to present (needs to have a mongod server with ssl support, 2.4 or higher)

Optional sslKey

sslKey: string

String or buffer containing the certificate private key we wish to present (needs to have a mongod server with ssl support, 2.4 or higher)

Optional sslPass

sslPass: string | Buffer

String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher)

Optional sslValidate

sslValidate: boolean

Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher). Default: true

Optional subscribers

subscribers: (string | Function)[]

Subscribers to be loaded for this connection. Accepts both subscriber classes and directories where from subscribers need to be loaded. Directories support glob patterns.

Optional synchronize

synchronize: boolean

Indicates if database schema should be auto created on every application launch. Be careful with this option and don't use this in production - otherwise you can lose production data. This option is useful during debug and development. Alternative to it, you can use CLI and run schema:sync command.

Note that for MongoDB database it does not create schema, because MongoDB is schemaless. Instead, it syncs just by creating indices.

type

type: "mongodb"

Database type.

Optional url

url: string

Connection url where perform connection to.

Optional useNewUrlParser

useNewUrlParser: boolean

Determines whether or not to use the new url parser. Default: false

Optional username

username: string

Database username.

Optional validateOptions

validateOptions: boolean | any

Validate MongoClient passed in options for correctness. Default: false

Optional w

w: string | number

The write concern.

Optional wtimeout

wtimeout: number

The write concern timeout value.

Generated using TypeDoc