Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MongoClient

Hierarchy

Index

Constructors

constructor

Methods

close

  • close(callback: MongoCallback<void>): void
  • close(force?: boolean): Promise<void>
  • close(force: boolean, callback: MongoCallback<void>): void

connect

  • Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/ Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.

    Returns Promise<MongoClient>

  • Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/ Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.

    Parameters

    • url: string

      The connection URI string.

    • callback: MongoCallback<Db>

      The command result callback.

    Returns void

  • Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/ Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.

    Parameters

    • url: string

      The connection URI string.

    • Optional options: MongoClientOptions

      Optional settings.

    Returns Promise<Db>

  • Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/ Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.

    Parameters

    Returns void

db

  • Create a new Db instance sharing the current socket connections. Be aware that the new db instances are related in a parent-child relationship to the original instance so that events are correctly emitted on child db instances. Child db instances are cached so performing db('db1') twice will return the same instance. You can control these behaviors with the options noListener and returnNonCachedInstance.

    see

    http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#db

    Parameters

    • Optional dbName: string

      The name of the database we want to use. If not provided, use database name from connection string.

    • Optional options: MongoClientCommonOption

      Optional settings.

    Returns Db

isConnected

logout

  • logout(callback: MongoCallback<any>): void
  • logout(options?: object): Promise<any>
  • logout(options: object, callback: MongoCallback<any>): void

startSession

watch

withSession

  • withSession(operation: function): Promise<void>
  • withSession(options: SessionOptions, operation: function): Promise<void>

Static connect

  • Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/ Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.

    Parameters

    • url: string

      The connection URI string.

    • callback: MongoCallback<Db>

      The command result callback.

    Returns void

  • Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/ Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.

    Parameters

    • url: string

      The connection URI string.

    • Optional options: MongoClientOptions

      Optional settings.

    Returns Promise<Db>

  • Connect to MongoDB using a url as documented at docs.mongodb.org/manual/reference/connection-string/ Note that for replicasets the replicaSet query parameter is required in the 2.0 driver.

    Parameters

    Returns void

Generated using TypeDoc