@types/mongodb

  • Version 3.6.17
  • Published
  • 209 kB
  • 2 dependencies
  • MIT license

Install

npm i @types/mongodb
yarn add @types/mongodb
pnpm add @types/mongodb

Overview

TypeScript definitions for MongoDB

Index

Functions

Classes

Interfaces

Enums

Type Aliases

Functions

function connect

connect: {
(uri: string, options?: MongoClientOptions): Promise<MongoClient>;
(uri: string, callback: MongoCallback<MongoClient>): void;
(
uri: string,
options: MongoClientOptions,
callback: MongoCallback<MongoClient>
): void;
};

    Classes

    class AggregationCursor

    class AggregationCursor<T = Default> extends Cursor<T> {}
    • Creates a new Aggregation Cursor instance (INTERNAL TYPE, do not instantiate directly)

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html

    method batchSize

    batchSize: (value: number) => AggregationCursor<T>;
    • Set the batch size for the cursor

      Parameter value

      The number of documents to return per batch. See .

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#batchSize

    method clone

    clone: () => AggregationCursor<T>;
    • Clone the cursor

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#clone

    method close

    close: {
    (): Promise<AggregationCursorResult>;
    (callback: MongoCallback<object>): void;
    };
    • Close the cursor, sending a AggregationCursor command and emitting close.

      Parameter callback

      The result callback

      Returns

      Promise if no callback is passed

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#close

    method each

    each: (callback: MongoCallback<AggregationCursorResult>) => void;
    • Iterates over all the documents for this cursor. As with cursor.toArray(), not all of the elements will be iterated if this cursor had been previously accessed. In that case, cursor.rewind() can be used to reset the cursor. However, unlike cursor.toArray(), the cursor will only hold a maximum of batch size elements at any given time if batch size is specified. Otherwise, the caller is responsible for making sure that the entire result can fit the memory.

      Parameter callback

      The result callback

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#each

      Deprecated

      use AggregationCursor.forEach() instead

    method explain

    explain: {
    (
    verbosity?: string | boolean,
    callback?: MongoCallback<AggregationCursorResult>
    ): Promise<AggregationCursorResult>;
    (callback?: MongoCallback<object>): void;
    };
    • Execute the explain for the cursor. For backwards compatibility, a verbosity of true is interpreted as allPlansExecution and false as queryPlanner. Prior to server version 3.6, aggregate() ignores the verbosity parameter and executes in queryPlanner.

      Parameter verbosity

      An optional mode in which to run the explain

      Parameter callback

      The result callback

      Returns

      Promise if no callback is passed

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#explain

    method geoNear

    geoNear: (document: object) => AggregationCursor<T>;
    • Add a geoNear stage to the aggregation pipeline

      Parameter document

      The geoNear stage document

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#geoNear

    method group

    group: <U = T>(document: object) => AggregationCursor<U>;
    • Add a group stage to the aggregation pipeline

      Parameter document

      The group stage document

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#group

    method hasNext

    hasNext: { (): Promise<boolean>; (callback: MongoCallback<boolean>): void };
    • Check if there is any document still available in the cursor

      Parameter callback

      The result callback

      Returns

      Promise if no callback is passed

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#hasNext

    method isClosed

    isClosed: () => boolean;
    • Is the cursor closed

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#isClosed

    method limit

    limit: (value: number) => AggregationCursor<T>;
    • Add a limit stage to the aggregation pipeline

      Parameter limit

      The state limit value

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#limit

    method lookup

    lookup: (document: object) => AggregationCursor<T>;
    • Add a lookup stage to the aggregation pipeline

      Parameter document

      The lookup stage document

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#lookup

    method match

    match: (document: object) => AggregationCursor<T>;
    • Add a match stage to the aggregation pipeline

      Parameter document

      The match stage document

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#match

    method maxTimeMS

    maxTimeMS: (value: number) => AggregationCursor<T>;
    • Add a maxTimeMS stage to the aggregation pipeline

      Parameter value

      The state maxTimeMS value

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#maxTimeMS

    method next

    next: { (): Promise<T | null>; (callback: MongoCallback<T>): void };
    • Get the next available document from the cursor, returns null if no more documents are available

      Parameter callback

      The result callback

      Returns

      Promise if no callback is passed

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#next

    method out

    out: (destination: string) => AggregationCursor<T>;
    • Add a out stage to the aggregation pipeline

      Parameter destination

      The destination name

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#out

    method project

    project: <U = T>(document: object) => AggregationCursor<U>;
    • Add a project stage to the aggregation pipeline

      Parameter document

      The project stage document

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#project

    method read

    read: (size: number) => string | Buffer | void;
    • The read() method pulls some data out of the internal buffer and returns it. If there is no data available, then it will return null.

      Parameter size

      Optional argument to specify how much data to read

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#read

    method redact

    redact: (document: object) => AggregationCursor<T>;
    • Add a redact stage to the aggregation pipeline

      Parameter document

      The redact stage document.

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#redact

    method rewind

    rewind: () => AggregationCursor<T>;
    • Resets the cursor

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#rewind

    method skip

    skip: (value: number) => AggregationCursor<T>;
    • Add a skip stage to the aggregation pipeline

      Parameter value

      The state skip value

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#setEncoding

    method sort

    sort: (document: object) => AggregationCursor<T>;
    • Add a sort stage to the aggregation pipeline

      Parameter document

      The sort stage document

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#sort

    method toArray

    toArray: { (): Promise<T[]>; (callback: MongoCallback<T[]>): void };
    • Returns an array of documents. The caller is responsible for making sure that there is enough memory to store the results. Note that the array only contain partial results when this cursor had been previously accessed. In that case, cursor.rewind() can be used to reset the cursor.

      Parameter callback

      The result callback

      Returns

      Promise if no callback is passed

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#toArray

    method unshift

    unshift: (chunk: Buffer | string) => void;
    • This is useful in certain cases where a stream is being consumed by a parser, which needs to "un-consume" some data that it has optimistically pulled out of the source, so that the stream can be passed on to some other party.

      Parameter chunk

      Chunk of data to unshift onto the read queue

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#unshift

    method unwind

    unwind: <U = T>(
    field:
    | string
    | {
    path: string;
    includeArrayIndex?: string;
    preserveNullAndEmptyArrays?: boolean;
    }
    ) => AggregationCursor<U>;
    • Add a unwind stage to the aggregation pipeline

      Parameter field

      The unwind field name or stage document.

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#unwind

    class BulkWriteError

    class BulkWriteError extends MongoError {}
    • An error indicating an unsuccessful Bulk Write

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/BulkWriteError.html

    class ChangeStream

    class ChangeStream<
    TSchema extends { [key: string]: any } = DefaultSchema
    > extends TypedEventEmitter<ChangeStreamEvents<TSchema>> {}
    • Creates a new Change Stream instance. Normally created using Collection.watch().

      Parameter parent

      The parent object that created this change stream

      Parameter pipeline

      An array of through which to pass change stream documents

      Parameter options

      Optional settings

      See Also

      • https://mongodb.github.io/node-mongodb-native/3.6/api/ChangeStream.html

    constructor

    constructor(
    parent: MongoClient | Db | Collection<any>,
    pipeline: object[],
    options?: ChangeStreamOptions
    );

      property resumeToken

      resumeToken: ResumeToken;

        method close

        close: { (): Promise<any>; (callback: MongoCallback<any>): void };
        • Close the Change Stream

          Parameter callback

          The result callback

          Returns

          Promise if no callback is passed

          See Also

          • https://mongodb.github.io/node-mongodb-native/3.6/api/ChangeStream.html#close

        method hasNext

        hasNext: { (): Promise<any>; (callback: MongoCallback<any>): void };
        • Check if there is any document still available in the Change Stream

          Parameter callback

          The result callback

          Returns

          Promise if no callback is passed

          See Also

          • https://mongodb.github.io/node-mongodb-native/3.6/api/ChangeStream.html#hasNext

        method isClosed

        isClosed: () => boolean;
        • Is the change stream closed

          See Also

          • https://mongodb.github.io/node-mongodb-native/3.6/api/ChangeStream.html#isClosed

        method next

        next: { (): Promise<any>; (callback: MongoCallback<any>): void };
        • Get the next available document from the Change Stream, returns null if no more documents are available.

          Parameter callback

          The result callback

          Returns

          Promise if no callback is passed

          See Also

          • https://mongodb.github.io/node-mongodb-native/3.6/api/ChangeStream.html#next

        method stream

        stream: (options?: { transform?: Function }) => Cursor;
        • Return a modified Readable stream including a possible transform method

          Parameter options

          Optional settings

          See Also

          • https://mongodb.github.io/node-mongodb-native/3.6/api/ChangeStream.html#stream

        class Code

        class Code {}
        • A class representation of the BSON Code type.

          Parameter name

          a string or function.

          Parameter scope

          an optional scope for the function.

          See Also

          • https://mongodb.github.io/node-mongodb-native/3.6/api/Code.html

        constructor

        constructor(code: string | Function, scope?: {});

          property code

          code: string | Function;

            property scope

            scope: any;

              class CommandCursor

              class CommandCursor extends Readable {}
              • Creates a new Command Cursor instance (INTERNAL TYPE, do not instantiate directly)

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html

              method batchSize

              batchSize: (value: number) => CommandCursor;
              • Set the batch size for the cursor.

                Parameter value

                The number of documents to return per batch. See .

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#batchSize

              method clone

              clone: () => CommandCursor;
              • Clone the cursor

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#clone

              method close

              close: {
              (): Promise<CommandCursorResult>;
              (callback: MongoCallback<object>): void;
              };
              • Close the cursor, sending a KillCursor command and emitting close.

                Parameter callback

                The result callback

                Returns

                Promise if no callback is passed

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#close

              method each

              each: (callback: MongoCallback<CommandCursorResult>) => void;
              • Iterates over all the documents for this cursor. As with cursor.toArray(), not all of the elements will be iterated if this cursor had been previously accessed. In that case, cursor.rewind() can be used to reset the cursor. However, unlike cursor.toArray(), the cursor will only hold a maximum of batch size elements at any given time if batch size is specified. Otherwise, the caller is responsible for making sure that the entire result can fit the memory.

                Parameter callback

                The result callback

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#each

              method hasNext

              hasNext: { (): Promise<boolean>; (callback: MongoCallback<boolean>): void };
              • Check if there is any document still available in the cursor

                Parameter callback

                The result callback

                Returns

                Promise if no callback is passed

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#hasNext

              method isClosed

              isClosed: () => boolean;
              • Is the cursor closed

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#isClosed

              method maxTimeMS

              maxTimeMS: (value: number) => CommandCursor;
              • Add a maxTimeMS stage to the aggregation pipeline

                Parameter value

                The state maxTimeMS value

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#maxTimeMS

              method next

              next: {
              (): Promise<CommandCursorResult>;
              (callback: MongoCallback<object>): void;
              };
              • Get the next available document from the cursor, returns null if no more documents are available.

                Parameter callback

                The result callback

                Returns

                Promise if no callback is passed

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#next

              method read

              read: (size: number) => string | Buffer | void;
              • The read() method pulls some data out of the internal buffer and returns it. If there is no data available, then it will return null.

                Parameter size

                Optional argument to specify how much data to read

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#read

              method rewind

              rewind: () => CommandCursor;
              • Resets the cursor

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#rewind

              method setReadPreference

              setReadPreference: (readPreference: ReadPreferenceOrMode) => CommandCursor;
              • Set the ReadPreference for the cursor

                Parameter readPreference

                The new read preference for the cursor

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#setReadPreference

              method toArray

              toArray: { (): Promise<any[]>; (callback: MongoCallback<any[]>): void };
              • Returns an array of documents. The caller is responsible for making sure that there is enough memory to store the results. Note that the array only contain partial results when this cursor had been previously accessed.

                Parameter callback

                The result callback

                Returns

                Promise if no callback is passed

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#toArray

              method unshift

              unshift: (chunk: Buffer | string) => void;
              • This is useful in certain cases where a stream is being consumed by a parser, which needs to "un-consume" some data that it has optimistically pulled out of the source, so that the stream can be passed on to some other party.

                Parameter chunk

                Chunk of data to unshift onto the read queue

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#unshift

              class Cursor

              class Cursor<T = Default> extends Readable {}
              • Creates a new Cursor instance (INTERNAL TYPE, do not instantiate directly)

                See Also

                • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html

              property readPreference

              readPreference: ReadPreference;

                property sortValue

                sortValue: string;

                  property timeout

                  timeout: boolean;

                    method [Symbol.asyncIterator]

                    [Symbol.asyncIterator]: () => AsyncIterableIterator<T>;

                      method addCursorFlag

                      addCursorFlag: (
                      flag:
                      | 'tailable'
                      | 'oplogReplay'
                      | 'noCursorTimeout'
                      | 'awaitData'
                      | 'partial'
                      | string,
                      value: boolean
                      ) => Cursor<T>;
                      • Add a cursor flag to the cursor

                        Parameter flag

                        The flag to set, must be one of following ['tailable', 'oplogReplay', 'noCursorTimeout', 'awaitData', 'partial'].

                        Parameter value

                        The flag boolean value.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#addCursorFlag

                      method addQueryModifier

                      addQueryModifier: (name: string, value: boolean | string | number) => Cursor<T>;
                      • Add a query modifier to the cursor query

                        Parameter name

                        The query modifier (must start with $, such as $orderby etc)

                        Parameter value

                        The modifier value.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#addQueryModifier

                      method batchSize

                      batchSize: (value: number) => Cursor<T>;
                      • Set the batch size for the cursor. The number of documents to return per batch. See .

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#batchSize

                      method clone

                      clone: () => Cursor<T>;
                      • Clone the cursor

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#clone

                      method close

                      close: {
                      (options?: { skipKillCursors: boolean }): Promise<CursorResult>;
                      (
                      options: { skipKillCursors: boolean },
                      callback: MongoCallback<CursorResult>
                      ): void;
                      (callback: MongoCallback<CursorResult>): void;
                      };
                      • Close the cursor, sending a KillCursor command and emitting close.

                        Parameter options

                        Optional settings

                        Parameter callback

                        The result callback

                        Returns

                        Promise if no callback is passed

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#close

                      method collation

                      collation: (value: CollationDocument) => Cursor<T>;
                      • Set the collation options for the cursor.

                        Parameter value

                        The cursor collation options (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#collation

                      method comment

                      comment: (value: string) => Cursor<T>;
                      • Add a comment to the cursor query allowing for tracking the comment in the log.

                        Parameter value

                        The comment attached to this query.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#comment

                      method count

                      count: {
                      (callback: MongoCallback<number>): void;
                      (applySkipLimit: boolean, callback: MongoCallback<number>): void;
                      (options: CursorCommentOptions, callback: MongoCallback<number>): void;
                      (
                      applySkipLimit: boolean,
                      options: CursorCommentOptions,
                      callback: MongoCallback<number>
                      ): void;
                      (applySkipLimit?: boolean, options?: CursorCommentOptions): Promise<number>;
                      };
                      • Get the count of documents for this cursor

                        Parameter applySkipLimit

                        Should the count command apply limit and skip settings on the cursor or in the passed in options.

                        Parameter options

                        Optional settings

                        Parameter callback

                        The result callback

                        Returns

                        Promise if no callback is passed

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#count

                      method explain

                      explain: {
                      (
                      verbosity?: string | boolean,
                      callback?: MongoCallback<CursorResult>
                      ): Promise<CursorResult>;
                      (callback?: MongoCallback<CursorResult>): void;
                      };
                      • Execute the explain for the cursor For backwards compatibility, a verbosity of true is interpreted as allPlansExecution and false as queryPlanner. Prior to server version 3.6, aggregate() ignores the verbosity parameter and executes in queryPlanner.

                        Parameter verbosity

                        An optional mode in which to run the explain.

                        Parameter callback

                        The result callback

                        Returns

                        Promise if no callback is passed

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#explain

                      method filter

                      filter: (filter: object) => Cursor<T>;
                      • Set the cursor query

                        Parameter filter

                        The filter object used for the cursor

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#filter

                      method forEach

                      forEach: {
                      (iterator: IteratorCallback<T>, callback: EndCallback): void;
                      (iterator: IteratorCallback<T>): Promise<void>;
                      };
                      • Iterates over all the documents for this cursor using the iterator, callback pattern.

                        Parameter iterator

                        The iteration callback

                        Parameter callback

                        The end callback

                        Returns

                        no callback supplied

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#forEach

                      method hasNext

                      hasNext: { (): Promise<boolean>; (callback: MongoCallback<boolean>): void };
                      • Check if there is any document still available in the cursor

                        Parameter callback

                        The result callback

                        Returns

                        Promise if no callback is passed

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#hasNext

                      method hint

                      hint: (hint: string | object) => Cursor<T>;
                      • Set the cursor hint

                        Parameter hint

                        If specified, then the query system will only consider plans using the hinted index.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#hint

                      method isClosed

                      isClosed: () => boolean;
                      • Is the cursor closed

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#isClosed

                      method limit

                      limit: (value: number) => Cursor<T>;
                      • Set the limit for the cursor

                        Parameter value

                        The limit for the cursor query

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#limit

                      method map

                      map: <U>(transform: (document: T) => U) => Cursor<U>;
                      • Map all documents using the provided function

                        Parameter transform

                        The mapping transformation method

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#map

                      method max

                      max: (max: object) => Cursor<T>;
                      • Set the cursor max

                        Parameter max

                        Specify a $max value to specify the exclusive upper bound for a specific index in order to constrain the results of find(). The $max specifies the upper bound for all keys of a specific index in order.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#max

                      method maxAwaitTimeMS

                      maxAwaitTimeMS: (value: number) => Cursor<T>;
                      • Set a maxAwaitTimeMS on a tailing cursor query to allow to customize the timeout value for the option awaitData (Only supported on MongoDB 3.2 or higher, ignored otherwise)

                        Parameter value

                        Number of milliseconds to wait before aborting the tailed query

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#maxAwaitTimeMS

                      method maxScan

                      maxScan: (maxScan: object) => Cursor<T>;
                      • Set the cursor maxScan

                        Parameter maxScan

                        Constrains the query to only scan the specified number of documents when fulfilling the query

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#maxScan

                      method maxTimeMS

                      maxTimeMS: (value: number) => Cursor<T>;
                      • Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher)

                        Parameter value

                        Number of milliseconds to wait before aborting the query.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#maxTimeMS

                      method min

                      min: (min: object) => Cursor<T>;
                      • Set the cursor min

                        Parameter min

                        Specify a $min value to specify the inclusive lower bound for a specific index in order to constrain the results of find(). The $min specifies the lower bound for all keys of a specific index in order.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#min

                      method next

                      next: { (): Promise<T | null>; (callback: MongoCallback<T>): void };
                      • Get the next available document from the cursor, returns null if no more documents are available.

                        Parameter callback

                        The result callback

                        Returns

                        Promise if no callback is passed

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#next

                      method project

                      project: <U = T>(
                      value: SchemaMember<T, ProjectionOperators | number | boolean | any>
                      ) => Cursor<U>;
                      • Sets a field projection for the query

                        Parameter value

                        The field projection object

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#project

                      method read

                      read: (size?: number) => string | Buffer | void;
                      • The read() method pulls some data out of the internal buffer and returns it. If there is no data available, then it will return null.

                        Parameter size

                        Optional argument to specify how much data to read.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#read

                      method returnKey

                      returnKey: (returnKey: boolean) => Cursor<T>;
                      • Set the cursor returnKey. If set to true, modifies the cursor to only return the index field or fields for the results of the query, rather than documents. If set to true and the query does not use an index to perform the read operation, the returned documents will not contain any fields.

                        Parameter returnKey

                        the returnKey value.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#returnKey

                      method rewind

                      rewind: () => void;
                      • Resets the cursor

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#rewind

                      method setCursorOption

                      setCursorOption: (field: string, value: object) => Cursor<T>;
                      • Set a node.js specific cursor option

                        Parameter field

                        The cursor option to set ['numberOfRetries', 'tailableRetryInterval'].

                        Parameter value

                        The field value

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#setCursorOption

                      method setReadPreference

                      setReadPreference: (readPreference: ReadPreferenceOrMode) => Cursor<T>;
                      • Set the ReadPreference for the cursor.

                        Parameter readPreference

                        The new read preference for the cursor

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#setReadPreference

                      method showRecordId

                      showRecordId: (showRecordId: boolean) => Cursor<T>;
                      • Set the cursor showRecordId

                        Parameter showRecordId

                        The $showDiskLoc option has now been deprecated and replaced with the showRecordId field. $showDiskLoc will still be accepted for OP_QUERY stye find.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#showRecordId

                      method skip

                      skip: (value: number) => Cursor<T>;
                      • Set the skip for the cursor

                        Parameter value

                        The skip for the cursor query.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#skip

                      method snapshot

                      snapshot: (snapshot: object) => Cursor<T>;
                      • Set the cursor snapshot

                        Parameter snapshot

                        The $snapshot operator prevents the cursor from returning a document more than once because an intervening write operation results in a move of the document.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#snapshot

                      method sort

                      sort: (
                      keyOrList: string | Array<[string, number]> | SortOptionObject<T>,
                      direction?: number
                      ) => Cursor<T>;
                      • Sets the sort order of the cursor query

                        Parameter keyOrList

                        The key or keys set for the sort

                        Parameter direction

                        The direction of the sorting (1 or -1).

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#sort

                      method stream

                      stream: (options?: { transform?: (document: T) => any }) => Cursor<T>;
                      • Return a modified Readable stream including a possible transform method

                        Parameter options

                        Optional settings

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#stream

                      method toArray

                      toArray: { (): Promise<T[]>; (callback: MongoCallback<T[]>): void };
                      • Returns an array of documents. The caller is responsible for making sure that there is enough memory to store the results. Note that the array only contains partial results when this cursor had been previously accessed. In that case, cursor.rewind() can be used to reset the cursor.

                        Parameter callback

                        The result callback

                        Returns

                        Promise if no callback is passed

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#toArray

                      method transformStream

                      transformStream: (options?: { transform?: (document: T) => any }) => Cursor<T>;
                      • Return a modified Readable stream that applies a given transform function, if supplied. If none supplied, returns a stream of unmodified docs.

                        Parameter options

                        Optional settings

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#transformStream

                      method unshift

                      unshift: (chunk: Buffer | string) => void;
                      • This is useful in certain cases where a stream is being consumed by a parser, which needs to "un-consume" some data that it has optimistically pulled out of the source, so that the stream can be passed on to some other party.

                        Parameter chunk

                        Chunk of data to unshift onto the read queue.

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#unshift

                      class Db

                      class Db extends EventEmitter {}
                      • Creates a new Db instance

                        Parameter databaseName

                        The name of the database this instance represents.

                        Parameter topology

                        The server topology for the database.

                        Parameter options

                        Optional settings

                        Returns

                        Db instance

                        See Also

                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html

                      constructor

                      constructor(
                      databaseName: string,
                      serverConfig: Server | ReplSet | Mongos,
                      options?: DbCreateOptions
                      );

                        property bufferMaxEntries

                        bufferMaxEntries: number;

                          property databaseName

                          databaseName: string;

                            property native_parser

                            native_parser: boolean;

                              property options

                              options: any;

                                property serverConfig

                                serverConfig: Server | ReplSet | Mongos;

                                  property slaveOk

                                  slaveOk: boolean;

                                    property writeConcern

                                    writeConcern: WriteConcern;

                                      method addUser

                                      addUser: {
                                      (username: string, password: string, callback: MongoCallback<any>): void;
                                      (
                                      username: string,
                                      password: string,
                                      options?: DbAddUserOptions
                                      ): Promise<any>;
                                      (
                                      username: string,
                                      password: string,
                                      options: DbAddUserOptions,
                                      callback: MongoCallback<any>
                                      ): void;
                                      };
                                      • Add a user to the database

                                        Parameter username

                                        The username

                                        Parameter password

                                        The password

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The command result callback

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#addUser

                                      method admin

                                      admin: () => Admin;
                                      • Return the Admin db instance

                                        Returns

                                        the new Admin db instance

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#admin

                                      method collection

                                      collection: {
                                      <TSchema = any>(
                                      name: string,
                                      callback?: MongoCallback<Collection<TSchema>>
                                      ): Collection<TSchema>;
                                      <TSchema = any>(
                                      name: string,
                                      options: DbCollectionOptions,
                                      callback?: MongoCallback<Collection<TSchema>>
                                      ): Collection<TSchema>;
                                      };
                                      • Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you can use it without a callback in the following way: const collection = db.collection('mycollection');

                                        Parameter name

                                        The collection name you wish to access

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The collection result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#collection

                                      method collections

                                      collections: {
                                      (): Promise<Array<Collection<Default>>>;
                                      (callback: MongoCallback<Collection<any>[]>): void;
                                      };
                                      • Fetch all collections for the current db.

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The collection result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#collections

                                      method command

                                      command: {
                                      (command: object, callback: MongoCallback<any>): void;
                                      (
                                      command: object,
                                      options?: {
                                      readPreference?: ReadPreferenceOrMode;
                                      session?: ClientSession;
                                      }
                                      ): Promise<any>;
                                      (
                                      command: object,
                                      options: {
                                      readPreference: ReadPreferenceOrMode;
                                      session?: ClientSession;
                                      },
                                      callback: MongoCallback<any>
                                      ): void;
                                      };
                                      • Execute a command

                                        Parameter command

                                        The command hash

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The command result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#command

                                      method createCollection

                                      createCollection: {
                                      <TSchema = any>(
                                      name: string,
                                      callback: MongoCallback<Collection<TSchema>>
                                      ): void;
                                      <TSchema = any>(name: string, options?: CollectionCreateOptions): Promise<
                                      Collection<TSchema>
                                      >;
                                      <TSchema = any>(
                                      name: string,
                                      options: CollectionCreateOptions,
                                      callback: MongoCallback<Collection<TSchema>>
                                      ): void;
                                      };
                                      • Create a new collection on a server with the specified options. Use this to create capped collections. More information about command options available at https://docs.mongodb.com/v3.6/reference/command/create/

                                        Parameter name

                                        The collection name we wish to access

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The results callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#createCollection

                                      method createIndex

                                      createIndex: {
                                      (
                                      name: string,
                                      fieldOrSpec: string | object,
                                      callback: MongoCallback<any>
                                      ): void;
                                      (
                                      name: string,
                                      fieldOrSpec: string | object,
                                      options?: IndexOptions
                                      ): Promise<any>;
                                      (
                                      name: string,
                                      fieldOrSpec: string | object,
                                      options: IndexOptions,
                                      callback: MongoCallback<any>
                                      ): void;
                                      };
                                      • Creates an index on the db and collection.

                                        Parameter name

                                        Name of the collection to create the index on

                                        Parameter fieldOrSpec

                                        Defines the index

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The results callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#createIndex

                                      method dropCollection

                                      dropCollection: {
                                      (name: string): Promise<boolean>;
                                      (name: string, callback: MongoCallback<boolean>): void;
                                      };
                                      • Drop a collection from the database, removing it permanently. New accesses will create a new collection.

                                        Parameter name

                                        Name of collection to drop

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The results callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#dropCollection

                                      method dropDatabase

                                      dropDatabase: { (): Promise<any>; (callback: MongoCallback<any>): void };
                                      • Drop a database, removing it permanently from the server.

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The results callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#dropDatabase

                                      method executeDbAdminCommand

                                      executeDbAdminCommand: {
                                      (command: object, callback: MongoCallback<any>): void;
                                      (
                                      command: object,
                                      options?: {
                                      readPreference?: ReadPreferenceOrMode;
                                      session?: ClientSession;
                                      }
                                      ): Promise<any>;
                                      (
                                      command: object,
                                      options: {
                                      readPreference?: ReadPreferenceOrMode;
                                      session?: ClientSession;
                                      },
                                      callback: MongoCallback<any>
                                      ): void;
                                      };
                                      • Runs a command on the database as admin.

                                        Parameter command

                                        The command hash

                                        Parameter options

                                        Optional Settings

                                        Parameter callback

                                        The command result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#executeDbAdminCommand

                                      method indexInformation

                                      indexInformation: {
                                      (name: string, callback: MongoCallback<any>): void;
                                      (
                                      name: string,
                                      options?: { full?: boolean; readPreference?: ReadPreferenceOrMode }
                                      ): Promise<any>;
                                      (
                                      name: string,
                                      options: { full?: boolean; readPreference?: ReadPreferenceOrMode },
                                      callback: MongoCallback<any>
                                      ): void;
                                      };
                                      • Retrieves this collections index info.

                                        Parameter name

                                        The name of the collection

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The command result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#indexInformation

                                      method listCollections

                                      listCollections: (
                                      filter?: object,
                                      options?: {
                                      nameOnly?: boolean;
                                      batchSize?: number;
                                      readPreference?: ReadPreferenceOrMode;
                                      session?: ClientSession;
                                      }
                                      ) => CommandCursor;
                                      • Get the list of all collection information for the specified db.

                                        Parameter filter

                                        Query to filter collections by

                                        Parameter options

                                        Optional settings

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#listCollections

                                      method profilingInfo

                                      profilingInfo: {
                                      (callback: MongoCallback<any>): void;
                                      (options?: { session?: ClientSession }): Promise<void>;
                                      (options: { session?: ClientSession }, callback: MongoCallback<void>): void;
                                      };
                                      • Retrieve the current profiling information for MongoDB

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#profilingInfo

                                        Deprecated

                                        Query the system.profile collection directly.

                                      method profilingLevel

                                      profilingLevel: {
                                      (callback: MongoCallback<ProfilingLevel>): void;
                                      (options?: { session?: ClientSession }): Promise<ProfilingLevel>;
                                      (
                                      options: { session?: ClientSession },
                                      callback: MongoCallback<ProfilingLevel>
                                      ): void;
                                      };
                                      • Retrieve the current profiling Level for MongoDB

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The command result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#profilingLevel

                                      method removeUser

                                      removeUser: {
                                      (username: string, callback: MongoCallback<any>): void;
                                      (username: string, options?: CommonOptions): Promise<any>;
                                      (
                                      username: string,
                                      options: CommonOptions,
                                      callback: MongoCallback<any>
                                      ): void;
                                      };
                                      • Remove a user from a database

                                        Parameter username

                                        The username

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The command result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#removeUser

                                      method renameCollection

                                      renameCollection: {
                                      <TSchema = any>(
                                      fromCollection: string,
                                      toCollection: string,
                                      callback: MongoCallback<Collection<TSchema>>
                                      ): void;
                                      <TSchema = any>(
                                      fromCollection: string,
                                      toCollection: string,
                                      options?: { dropTarget?: boolean }
                                      ): Promise<Collection<TSchema>>;
                                      <TSchema = any>(
                                      fromCollection: string,
                                      toCollection: string,
                                      options: { dropTarget?: boolean },
                                      callback: MongoCallback<Collection<TSchema>>
                                      ): void;
                                      };
                                      • Rename a collection

                                        Parameter fromCollection

                                        Name of current collection to rename

                                        Parameter toCollection

                                        New name of of the collection

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The command result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#renameCollection

                                      method setProfilingLevel

                                      setProfilingLevel: {
                                      (level: ProfilingLevel, callback: MongoCallback<ProfilingLevel>): void;
                                      (
                                      level: ProfilingLevel,
                                      options?: { session?: ClientSession }
                                      ): Promise<ProfilingLevel>;
                                      (
                                      level: ProfilingLevel,
                                      options: { session?: ClientSession },
                                      callback: MongoCallback<ProfilingLevel>
                                      ): void;
                                      };
                                      • Set the current profiling level of MongoDB

                                        Parameter level

                                        The new profiling level (off, slow_only, all)

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The command result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#setProfilingLevel

                                      method stats

                                      stats: {
                                      (callback: MongoCallback<any>): void;
                                      (options?: { scale?: number }): Promise<any>;
                                      (options: { scale?: number }, callback: MongoCallback<any>): void;
                                      };
                                      • Get all the db statistics.

                                        Parameter options

                                        Optional settings

                                        Parameter callback

                                        The command result callback

                                        Returns

                                        Promise if no callback is passed

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#stats

                                      method unref

                                      unref: () => void;
                                      • Unref all sockets

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#unref

                                      method watch

                                      watch: <TSchema extends object = { _id: any }>(
                                      pipeline?: object[],
                                      options?: ChangeStreamOptions & { session?: ClientSession }
                                      ) => ChangeStream<TSchema>;
                                      • Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this database. Will ignore all changes to system collections.

                                        Parameter pipeline

                                        An array of through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.

                                        Parameter options

                                        Optional settings

                                        Returns

                                        ChangeStream instance

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Db.html#watch

                                      class GridFSBucket

                                      class GridFSBucket extends EventEmitter {}
                                      • Constructor for a streaming GridFS interface

                                        Parameter db

                                        A db handle

                                        Parameter options

                                        Optional settings

                                        See Also

                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html

                                      constructor

                                      constructor(db: Db, options?: GridFSBucketOptions);

                                        method delete

                                        delete: (id: any, callback?: GridFSBucketErrorCallback) => void;
                                        • Deletes a file with the given id

                                          Parameter id

                                          The id of the file doc

                                          Parameter callback

                                          The result callback

                                          See Also

                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html#delete

                                        method drop

                                        drop: (callback?: GridFSBucketErrorCallback) => void;
                                        • Removes this bucket's files collection, followed by its chunks collection

                                          Parameter callback

                                          The result callback

                                          See Also

                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html#drop

                                        method find

                                        find: (filter: object, options?: GridFSBucketFindOptions) => Cursor<any>;
                                        • Convenience wrapper around find on the files collection

                                          Parameter filter

                                          The filter object used to find items inside the bucket

                                          Parameter options

                                          Optional settings for cursor

                                          See Also

                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html#find

                                        method openDownloadStream

                                        openDownloadStream: (
                                        id: any,
                                        options?: { start: number; end: number }
                                        ) => GridFSBucketReadStream;
                                        • Returns a readable stream (GridFSBucketReadStream) for streaming file data from GridFS.

                                          Parameter id

                                          The id of the file doc

                                          Parameter options

                                          Optional settings

                                          See Also

                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html#openDownloadStream

                                        method openDownloadStreamByName

                                        openDownloadStreamByName: (
                                        filename: string,
                                        options?: { revision: number; start: number; end: number }
                                        ) => GridFSBucketReadStream;
                                        • Returns a readable stream () for streaming the file with the given name from GridFS. If there are multiple files with the same name, this will stream the most recent file with the given name (as determined by the uploadDate field). You can set the revision option to change this behavior.

                                          Parameter filename

                                          The name of the file to stream

                                          Parameter options

                                          Optional settings

                                          See Also

                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html#openDownloadStreamByName

                                        method openUploadStream

                                        openUploadStream: (
                                        filename: string,
                                        options?: GridFSBucketOpenUploadStreamOptions
                                        ) => GridFSBucketWriteStream;
                                        • Returns a writable stream (GridFSBucketWriteStream) for writing buffers to GridFS. The stream's id property contains the resulting file's id.

                                          Parameter filename

                                          The value of the filename key in the files doc

                                          Parameter options

                                          Optional settings

                                          See Also

                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html#openUploadStream

                                        method openUploadStreamWithId

                                        openUploadStreamWithId: (
                                        id: GridFSBucketWriteStreamId,
                                        filename: string,
                                        options?: GridFSBucketOpenUploadStreamOptions
                                        ) => GridFSBucketWriteStream;
                                        • Returns a writable stream () for writing buffers to GridFS for a custom file id. The stream's id property contains the resulting file's id.

                                          Parameter id

                                          A custom id used to identify the file

                                          Parameter filename

                                          The value of the filename key in the files doc

                                          Parameter options

                                          Optional settings

                                          See Also

                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html#openUploadStreamWithId

                                        method rename

                                        rename: (
                                        id: any,
                                        filename: string,
                                        callback?: GridFSBucketErrorCallback
                                        ) => void;
                                        • Renames the file with the given _id to the given string

                                          Parameter id

                                          The id of the file to rename

                                          Parameter filename

                                          New name for the file

                                          Parameter callback

                                          The result callback

                                          See Also

                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html#rename

                                        class GridFSBucketReadStream

                                        class GridFSBucketReadStream extends Readable {}
                                        • A readable stream that enables you to read buffers from GridFS. Do not instantiate this class directly. Use instead.

                                          Parameter chunks

                                          Handle for chunks collection

                                          Parameter files

                                          Handle for files collection

                                          Parameter readPreference

                                          The read preference to use

                                          Parameter filter

                                          The query to use to find the file document

                                          Parameter options

                                          Optional settings

                                          See Also

                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucketReadStream.html

                                        constructor

                                        constructor(
                                        chunks: Collection<any>,
                                        files: Collection<any>,
                                        readPreference: {},
                                        filter: {},
                                        options?: GridFSBucketReadStreamOptions
                                        );

                                          property id

                                          id: any;

                                            class GridFSBucketWriteStream

                                            class GridFSBucketWriteStream extends Writable {}
                                            • A writable stream that enables you to write buffers to GridFS. Do not instantiate this class directly. Use instead.

                                              Parameter bucket

                                              Handle for this stream's corresponding bucket

                                              Parameter filename

                                              The value of the filename key in the files doc

                                              Parameter options

                                              Optional settings

                                              See Also

                                              • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucketWriteStream.html

                                            constructor

                                            constructor(
                                            bucket: GridFSBucket,
                                            filename: string,
                                            options?: GridFSBucketWriteStreamOptions
                                            );

                                              property id

                                              id: any;

                                                method abort

                                                abort: (callback?: GridFSBucketErrorCallback) => void;
                                                • Places this write stream into an aborted state (all future writes fail) and deletes all chunks that have already been written.

                                                  Parameter callback

                                                  called when chunks are successfully removed or error occurred

                                                  See Also

                                                  • https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucketWriteStream.html#abort

                                                class Logger

                                                class Logger {}
                                                • Creates a new Logger instance

                                                  Parameter className

                                                  The Class name associated with the logging instance

                                                  Parameter options

                                                  Optional settings

                                                  See Also

                                                  • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html

                                                constructor

                                                constructor(className: string, options?: LoggerOptions);

                                                  method currentLogger

                                                  static currentLogger: () => log;
                                                  • Get the current logger function

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#.currentLogger

                                                  method debug

                                                  debug: (message: string, object: LoggerState) => void;
                                                  • Log a message at the debug level

                                                    Parameter message

                                                    The message to log

                                                    Parameter object

                                                    Additional meta data to log

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#debug

                                                  method error

                                                  error: (message: string, object: LoggerState) => void;
                                                  • Log a message at the error level

                                                    Parameter message

                                                    The message to log

                                                    Parameter object

                                                    Additional meta data to log

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#error

                                                  method filter

                                                  static filter: (type: string, values: string[]) => void;
                                                  • Set what classes to log.

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#.filter

                                                  method info

                                                  info: (message: string, object: LoggerState) => void;
                                                  • Log a message at the info level

                                                    Parameter message

                                                    The message to log

                                                    Parameter object

                                                    Additional meta data to log

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#info

                                                  method isDebug

                                                  isDebug: () => boolean;
                                                  • Is the logger set at debug level

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#isDebug

                                                  method isError

                                                  isError: () => boolean;
                                                  • Is the logger set at error level

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#isError

                                                  method isInfo

                                                  isInfo: () => boolean;
                                                  • Is the logger set at info level

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#isInfo

                                                  method isWarn

                                                  isWarn: () => boolean;
                                                  • Is the logger set at error level

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#isWarn

                                                  method reset

                                                  static reset: () => void;
                                                  • Resets the logger to default settings, error and no filtered classes

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#.reset

                                                  method setCurrentLogger

                                                  static setCurrentLogger: (log: log) => void;
                                                  • Set the current logger function

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#.setCurrentLogger

                                                  method setLevel

                                                  static setLevel: (level: string) => void;
                                                  • Set the current log level

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/Logger.html#.setLevel

                                                  class MongoBulkWriteError

                                                  class BulkWriteError extends MongoError {}
                                                  • An error indicating an unsuccessful Bulk Write

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/BulkWriteError.html

                                                  class MongoClient

                                                  class MongoClient extends EventEmitter {}
                                                  • Creates a new MongoClient instance

                                                    Parameter uri

                                                    The connection URI string

                                                    Parameter options

                                                    Optional settings

                                                    Parameter callback

                                                    The optional command result callback

                                                    Returns

                                                    MongoClient instance

                                                    See Also

                                                    • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html

                                                  constructor

                                                  constructor(uri: string, options?: MongoClientOptions);

                                                    property readPreference

                                                    readPreference: ReadPreference;

                                                      property writeConcern

                                                      writeConcern: WriteConcern;

                                                        method close

                                                        close: {
                                                        (callback: MongoCallback<void>): void;
                                                        (force?: boolean): Promise<void>;
                                                        (force: boolean, callback: MongoCallback<void>): void;
                                                        };
                                                        • Close the db and its underlying connections

                                                          Parameter force

                                                          Optional force close, emitting no events

                                                          Parameter callback

                                                          The optional result callback

                                                          Returns

                                                          Promise if no callback is passed

                                                          See Also

                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#close

                                                        method connect

                                                        static connect: {
                                                        (uri: string, callback: MongoCallback<MongoClient>): void;
                                                        (uri: string, options?: MongoClientOptions): Promise<MongoClient>;
                                                        (
                                                        uri: string,
                                                        options: MongoClientOptions,
                                                        callback: MongoCallback<MongoClient>
                                                        ): void;
                                                        };
                                                        • Connect to MongoDB using a url as documented at https://docs.mongodb.org/manual/reference/connection-string/

                                                          Parameter uri

                                                          The connection URI string

                                                          Parameter options

                                                          Optional settings

                                                          Parameter callback

                                                          The optional command result callback

                                                          Returns

                                                          Promise if no callback is passed

                                                          See Also

                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#.connect

                                                        • Connect to MongoDB using a url as documented at https://docs.mongodb.org/manual/reference/connection-string/

                                                          Parameter callback

                                                          The optional command result callback

                                                          Returns

                                                          Promise if no callback is passed

                                                          See Also

                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#connect

                                                        method db

                                                        db: (dbName?: string, options?: MongoClientCommonOption) => 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.

                                                          Parameter dbName

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

                                                          Parameter options

                                                          Optional settings

                                                          Returns

                                                          The Db object

                                                          See Also

                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#db

                                                        method isConnected

                                                        isConnected: (options?: MongoClientCommonOption) => boolean;
                                                        • Check if MongoClient is connected

                                                          Parameter options

                                                          Optional settings

                                                          Returns

                                                          Whether the MongoClient is connected or not

                                                          See Also

                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#isConnected

                                                        method startSession

                                                        startSession: (options?: SessionOptions) => ClientSession;
                                                        • Starts a new session on the server

                                                          Parameter options

                                                          Optional settings for a driver session~

                                                          Returns

                                                          Newly established session

                                                          See Also

                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#startSession

                                                        method watch

                                                        watch: <TSchema extends object = { _id: any }>(
                                                        pipeline?: object[],
                                                        options?: ChangeStreamOptions & { session?: ClientSession }
                                                        ) => ChangeStream<TSchema>;
                                                        • Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this cluster. Will ignore all changes to system collections, as well as the local, admin, and config databases.

                                                          Parameter pipeline

                                                          An array of through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.

                                                          Parameter options

                                                          Optional settings

                                                          Returns

                                                          ChangeStream instance

                                                          See Also

                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#watch

                                                        method withSession

                                                        withSession: {
                                                        (operation: (session: ClientSession) => Promise<any>): Promise<void>;
                                                        (
                                                        options: SessionOptions,
                                                        operation: (session: ClientSession) => Promise<any>
                                                        ): Promise<void>;
                                                        };
                                                        • Runs a given operation with an implicitly created session. The lifetime of the session will be handled without the need for user interaction. NOTE: presently the operation MUST return a Promise (either explicit or implicity as an async function)

                                                          Parameter options

                                                          Optional settings to be appled to implicitly created session

                                                          Parameter operation

                                                          An operation to execute with an implicitly created session. The signature of this MUST be (session) => {}

                                                          See Also

                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#withSession

                                                        class MongoError

                                                        class MongoError extends Error {}
                                                        • Creates a new MongoError

                                                          Parameter message

                                                          The error message

                                                          See Also

                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoError.html

                                                        constructor

                                                        constructor(message: string | object | Error);

                                                          property code

                                                          code?: string | number;

                                                            property errmsg

                                                            errmsg?: string;
                                                            • While not documented, the errmsg prop is AFAIK the only way to find out which unique index caused a duplicate key error. When you have multiple unique indexes on a collection, knowing which index caused a duplicate key error enables you to send better (more precise) error messages to the client/user (eg. "Email address must be unique" instead of "Both email address and username must be unique") – which caters for a better (app) user experience.

                                                              Details: (issue for mongoose, but the same applies for the native mongodb driver).

                                                              Note that in mongoose (the link above) the prop in question is called 'message' while in mongodb it is called 'errmsg'. This can be seen in multiple places in the source code, for example .

                                                            property errorLabels

                                                            readonly errorLabels: string[];

                                                              property name

                                                              name: string;

                                                                method create

                                                                static create: (options: string | Error | object) => MongoError;
                                                                • Creates a new MongoError object

                                                                  Parameter options

                                                                  The options used to create the error

                                                                  Returns

                                                                  A MongoError instance

                                                                  See Also

                                                                  • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoError.html#.create

                                                                  Deprecated

                                                                  Use new MongoError() instead

                                                                method hasErrorLabel

                                                                hasErrorLabel: (label: string) => boolean;
                                                                • Checks the error to see if it has an error label

                                                                  Parameter options

                                                                  The options used to create the error

                                                                  Returns

                                                                  true if the error has the provided error label

                                                                  See Also

                                                                  • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoError.html#hasErrorLabel

                                                                class MongoNetworkError

                                                                class MongoNetworkError extends MongoError {}
                                                                • An error indicating an issue with the network, including TCP errors and timeouts

                                                                  Parameter message

                                                                  The error message

                                                                  See Also

                                                                  • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoNetworkError.html

                                                                class MongoParseError

                                                                class MongoParseError extends MongoError {}
                                                                • An error used when attempting to parse a value (like a connection string)

                                                                  Parameter message

                                                                  The error message

                                                                  See Also

                                                                  • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoParseError.html

                                                                class Mongos

                                                                class Mongos extends EventEmitter {}
                                                                • Creates a new Mongos instance

                                                                  Parameter servers

                                                                  A seedlist of servers participating in the replicaset.

                                                                  Parameter options

                                                                  Optional settings

                                                                  See Also

                                                                  • https://mongodb.github.io/node-mongodb-native/3.6/api/Mongos.html

                                                                  Deprecated

                                                                constructor

                                                                constructor(servers: Server[], options?: MongosOptions);

                                                                  method connections

                                                                  connections: () => any[];

                                                                    class MongoServerSelectionError

                                                                    class MongoServerSelectionError extends MongoTimeoutError {}
                                                                    • An error signifying a client-side server selection error

                                                                      Parameter message

                                                                      The error message

                                                                      Parameter reason

                                                                      The reason the timeout occured

                                                                      See Also

                                                                      • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoServerSelectionError.html

                                                                    class MongoTimeoutError

                                                                    class MongoTimeoutError extends MongoError {}
                                                                    • An error signifying a client-side timeout event

                                                                      Parameter message

                                                                      The error message

                                                                      Parameter reason

                                                                      The reason the timeout occured

                                                                      See Also

                                                                      • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoTimeoutError.html

                                                                    property reason

                                                                    reason?: string | object;
                                                                    • An optional reason context for the timeout, generally an error saved during flow of monitoring and selecting servers

                                                                    class MongoWriteConcernError

                                                                    class MongoWriteConcernError extends MongoError {}
                                                                    • An error thrown when the server reports a writeConcernError

                                                                      Parameter message

                                                                      The error message

                                                                      Parameter reason

                                                                      The reason the timeout occured

                                                                      See Also

                                                                      • https://mongodb.github.io/node-mongodb-native/3.6/api/MongoWriteConcernError.html

                                                                    property result

                                                                    result?: {};
                                                                    • The result document (provided if ok: 1)

                                                                    class ReadPreference

                                                                    class ReadPreference {}
                                                                    • The **ReadPreference** class represents a MongoDB ReadPreference and is used to construct connections.

                                                                      See Also

                                                                      • https://docs.mongodb.com/v3.6/core/read-preference/

                                                                    constructor

                                                                    constructor(mode: ReadPreferenceMode, tags: {}, options?: ReadPreferenceOptions);

                                                                      property mode

                                                                      mode: ReadPreferenceMode;

                                                                        property NEAREST

                                                                        static NEAREST: string;

                                                                          property PRIMARY

                                                                          static PRIMARY: string;

                                                                            property PRIMARY_PREFERRED

                                                                            static PRIMARY_PREFERRED: string;

                                                                              property SECONDARY

                                                                              static SECONDARY: string;

                                                                                property SECONDARY_PREFERRED

                                                                                static SECONDARY_PREFERRED: string;

                                                                                  property tags

                                                                                  tags: ReadPreferenceTags;

                                                                                    method equals

                                                                                    equals: (readPreference: ReadPreference) => boolean;
                                                                                    • Are the two read preference equal

                                                                                      Parameter readPreference

                                                                                      the read preference with which to check equality

                                                                                      Returns

                                                                                      true if the two ReadPreferences are equivalent

                                                                                    method isValid

                                                                                    static isValid: (mode: string) => boolean;

                                                                                      method slaveOk

                                                                                      slaveOk: () => boolean;
                                                                                      • Indicates that this readPreference needs the "slaveOk" bit when sent over the wire

                                                                                        See Also

                                                                                        • https://docs.mongodb.com/v3.6/reference/mongodb-wire-protocol/#op-query

                                                                                      class ReplSet

                                                                                      class ReplSet extends EventEmitter {}
                                                                                      • Creates a new ReplSet instance

                                                                                        Parameter servers

                                                                                        A seedlist of servers participating in the replicaset.

                                                                                        Parameter options

                                                                                        Optional settings

                                                                                        See Also

                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/ReplSet.html

                                                                                        Deprecated

                                                                                      constructor

                                                                                      constructor(servers: Server[], options?: ReplSetOptions);

                                                                                        method connections

                                                                                        connections: () => any[];

                                                                                          class ResumeToken

                                                                                          class ResumeToken {}

                                                                                            class Server

                                                                                            class Server extends EventEmitter {}
                                                                                            • Creates a new Server instance

                                                                                              Parameter host

                                                                                              The host for the server, can be either an IP4, IP6 or domain socket style host.

                                                                                              Parameter port

                                                                                              The server port if IP4.

                                                                                              Parameter options

                                                                                              Optional settings

                                                                                              Returns

                                                                                              Server instance

                                                                                              See Also

                                                                                              • https://mongodb.github.io/node-mongodb-native/3.6/api/Server.html

                                                                                              Deprecated

                                                                                            constructor

                                                                                            constructor(host: string, port: number, options?: ServerOptions);

                                                                                              method connections

                                                                                              connections: () => any[];

                                                                                                Interfaces

                                                                                                interface AddUserOptions

                                                                                                interface AddUserOptions extends CommonOptions {}
                                                                                                • Options for adding a user to the database

                                                                                                  See Also

                                                                                                  • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#addUser

                                                                                                property customData

                                                                                                customData?: object;

                                                                                                  property fsync

                                                                                                  fsync: boolean;

                                                                                                    property roles

                                                                                                    roles?: object[];

                                                                                                      interface Admin

                                                                                                      interface Admin {}
                                                                                                      • Create a new Admin instance (INTERNAL TYPE, do not instantiate directly)

                                                                                                        Returns

                                                                                                        Collection instance

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html

                                                                                                      method addUser

                                                                                                      addUser: {
                                                                                                      (username: string, password: string, callback: MongoCallback<any>): void;
                                                                                                      (username: string, password: string, options?: AddUserOptions): Promise<any>;
                                                                                                      (
                                                                                                      username: string,
                                                                                                      password: string,
                                                                                                      options: AddUserOptions,
                                                                                                      callback: MongoCallback<any>
                                                                                                      ): void;
                                                                                                      };
                                                                                                      • Add a user to the database.

                                                                                                        Parameter username

                                                                                                        The username

                                                                                                        Parameter password

                                                                                                        The password

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#addUser

                                                                                                      method buildInfo

                                                                                                      buildInfo: {
                                                                                                      (options?: { session?: ClientSession }): Promise<any>;
                                                                                                      (options: { session?: ClientSession }, callback: MongoCallback<any>): void;
                                                                                                      (callback: MongoCallback<any>): void;
                                                                                                      };
                                                                                                      • Retrieve the server information for the current instance of the db client

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#buildInfo

                                                                                                      method command

                                                                                                      command: {
                                                                                                      (command: object, callback: MongoCallback<any>): void;
                                                                                                      (
                                                                                                      command: object,
                                                                                                      options?: { readPreference?: ReadPreferenceOrMode; maxTimeMS?: number }
                                                                                                      ): Promise<any>;
                                                                                                      (
                                                                                                      command: object,
                                                                                                      options: { readPreference?: ReadPreferenceOrMode; maxTimeMS?: number },
                                                                                                      callback: MongoCallback<any>
                                                                                                      ): void;
                                                                                                      };
                                                                                                      • Execute a command

                                                                                                        Parameter command

                                                                                                        The command hash

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#command

                                                                                                      method listDatabases

                                                                                                      listDatabases: {
                                                                                                      (options?: { nameOnly?: boolean; session?: ClientSession }): Promise<any>;
                                                                                                      (
                                                                                                      options: { nameOnly?: boolean; session?: ClientSession },
                                                                                                      callback: MongoCallback<any>
                                                                                                      ): void;
                                                                                                      (callback: MongoCallback<any>): void;
                                                                                                      };
                                                                                                      • List the available databases

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#listDatabases

                                                                                                      method ping

                                                                                                      ping: {
                                                                                                      (options?: { session?: ClientSession }): Promise<any>;
                                                                                                      (options: { session?: ClientSession }, callback: MongoCallback<any>): void;
                                                                                                      (callback: MongoCallback<any>): void;
                                                                                                      };
                                                                                                      • Ping the MongoDB server and retrieve results

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#ping

                                                                                                      method removeUser

                                                                                                      removeUser: {
                                                                                                      (username: string, callback: MongoCallback<any>): void;
                                                                                                      (username: string, options?: FSyncOptions): Promise<any>;
                                                                                                      (
                                                                                                      username: string,
                                                                                                      options: FSyncOptions,
                                                                                                      callback: MongoCallback<any>
                                                                                                      ): void;
                                                                                                      };
                                                                                                      • Remove a user from a database

                                                                                                        Parameter username

                                                                                                        The username

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#removeUser

                                                                                                      method replSetGetStatus

                                                                                                      replSetGetStatus: {
                                                                                                      (options?: { session?: ClientSession }): Promise<any>;
                                                                                                      (options: { session?: ClientSession }, callback: MongoCallback<any>): void;
                                                                                                      (callback: MongoCallback<any>): void;
                                                                                                      };
                                                                                                      • Get ReplicaSet status

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#replSetGetStatus

                                                                                                      method serverInfo

                                                                                                      serverInfo: { (): Promise<any>; (callback: MongoCallback<any>): void };
                                                                                                      • Retrieve the server information for the current instance of the db client

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#serverInfo

                                                                                                      method serverStatus

                                                                                                      serverStatus: {
                                                                                                      (options?: { session?: ClientSession }): Promise<any>;
                                                                                                      (options: { session?: ClientSession }, callback: MongoCallback<any>): void;
                                                                                                      (callback: MongoCallback<any>): void;
                                                                                                      };
                                                                                                      • Retrieve this db's server status.

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#serverStatus

                                                                                                      method validateCollection

                                                                                                      validateCollection: {
                                                                                                      (collectionNme: string, callback: MongoCallback<any>): void;
                                                                                                      (collectionNme: string, options?: object): Promise<any>;
                                                                                                      (collectionNme: string, options: object, callback: MongoCallback<any>): void;
                                                                                                      };
                                                                                                      • Validate an existing collection

                                                                                                        Parameter collectionNme

                                                                                                        The name of the collection to validate

                                                                                                        Parameter options

                                                                                                        Optional settings

                                                                                                        Parameter callback

                                                                                                        The command result callback

                                                                                                        Returns

                                                                                                        Promise if no callback is passed

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#validateCollection

                                                                                                      interface AutoEncryptionExtraOptions

                                                                                                      interface AutoEncryptionExtraOptions {}
                                                                                                      • Extra options related to the mongocryptd process.

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/AutoEncrypter.html#~AutoEncryptionExtraOptions

                                                                                                      property mongocryptdBypassSpawn

                                                                                                      mongocryptdBypassSpawn?: boolean;
                                                                                                      • If true, autoEncryption will not attempt to spawn a mongocryptd before connecting.

                                                                                                      property mongocryptdSpawnArgs

                                                                                                      mongocryptdSpawnArgs?: string[];
                                                                                                      • Command line arguments to use when auto-spawning a mongocryptd.

                                                                                                      property mongocryptdSpawnPath

                                                                                                      mongocryptdSpawnPath?: string;
                                                                                                      • The path to the mongocryptd executable on the system.

                                                                                                      property mongocryptdURI

                                                                                                      mongocryptdURI?: string;
                                                                                                      • A local process the driver communicates with to determine how to encrypt values in a command. Defaults to "mongodb:///var/mongocryptd.sock" if domain sockets are available or "mongodb://localhost:27020" otherwise.

                                                                                                      interface AutoEncryptionOptions

                                                                                                      interface AutoEncryptionOptions {}
                                                                                                      • Configuration options for a automatic client encryption.

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/AutoEncrypter.html#~AutoEncryptionOptions

                                                                                                      property bypassAutoEncryption

                                                                                                      bypassAutoEncryption?: boolean;
                                                                                                      • Allows the user to bypass auto encryption, maintaining implicit decryption.

                                                                                                      property extraOptions

                                                                                                      extraOptions?: AutoEncryptionExtraOptions;
                                                                                                      • Extra options related to the mongocryptd process.

                                                                                                      property keyVaultClient

                                                                                                      keyVaultClient?: MongoClient;
                                                                                                      • A MongoClient used to fetch keys from a key vault

                                                                                                      property keyVaultNamespace

                                                                                                      keyVaultNamespace?: string;
                                                                                                      • The namespace where keys are stored in the key vault.

                                                                                                      property kmsProviders

                                                                                                      kmsProviders?: KMSProviders;
                                                                                                      • Configuration options that are used by specific KMS providers during key generation, encryption, and decryption.

                                                                                                      property schemaMap

                                                                                                      schemaMap?: object;
                                                                                                      • A map of namespaces to a local JSON schema for encryption.

                                                                                                      interface BulkWriteOpResultObject

                                                                                                      interface BulkWriteOpResultObject {}
                                                                                                      • Returning object for Collection.bulkWrite operations

                                                                                                        See Also

                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#~BulkWriteOpResult

                                                                                                      property deletedCount

                                                                                                      deletedCount?: number;

                                                                                                        property insertedCount

                                                                                                        insertedCount?: number;

                                                                                                          property insertedIds

                                                                                                          insertedIds?: { [index: number]: any };

                                                                                                            property matchedCount

                                                                                                            matchedCount?: number;

                                                                                                              property modifiedCount

                                                                                                              modifiedCount?: number;

                                                                                                                property result

                                                                                                                result?: any;

                                                                                                                  property upsertedCount

                                                                                                                  upsertedCount?: number;

                                                                                                                    property upsertedIds

                                                                                                                    upsertedIds?: { [index: number]: any };

                                                                                                                      interface BulkWriteResult

                                                                                                                      interface BulkWriteResult {}
                                                                                                                      • Returning object from bulkWrite operations

                                                                                                                        See Also

                                                                                                                        • https://mongodb.github.io/node-mongodb-native/3.6/api/BulkWriteResult.html

                                                                                                                      property nInserted

                                                                                                                      nInserted: number;
                                                                                                                      • The number of documents inserted, excluding upserted documents.

                                                                                                                      property nMatched

                                                                                                                      nMatched: number;
                                                                                                                      • The number of documents selected for update.

                                                                                                                        If the update operation results in no change to the document, e.g. $set expression updates the value to the current value, nMatched can be greater than nModified.

                                                                                                                      property nModified

                                                                                                                      nModified: number;
                                                                                                                      • The number of existing documents updated.

                                                                                                                        If the update/replacement operation results in no change to the document, such as setting the value of the field to its current value, nModified can be less than nMatched

                                                                                                                      property nRemoved

                                                                                                                      nRemoved: number;
                                                                                                                      • The number of documents removed.

                                                                                                                      property nUpserted

                                                                                                                      nUpserted: number;
                                                                                                                      • The number of documents inserted by an .

                                                                                                                      property ok

                                                                                                                      ok: boolean;
                                                                                                                      • Evaluates to true if the bulk operation correctly executes

                                                                                                                      method getInsertedIds

                                                                                                                      getInsertedIds: () => object[];
                                                                                                                      • Returns an array of all inserted ids

                                                                                                                      method getLastOp

                                                                                                                      getLastOp: () => object;
                                                                                                                      • Retrieve lastOp if available

                                                                                                                      method getRawResponse

                                                                                                                      getRawResponse: () => object;
                                                                                                                      • Returns raw internal result

                                                                                                                      method getUpsertedIdAt

                                                                                                                      getUpsertedIdAt: (index: number) => BulkWriteResultUpsertedIdObject;
                                                                                                                      • Returns the upserted id at the given index

                                                                                                                        Parameter index

                                                                                                                        the number of the upserted id to return, returns undefined if no result for passed in index

                                                                                                                      method getUpsertedIds

                                                                                                                      getUpsertedIds: () => BulkWriteResultUpsertedIdObject[];
                                                                                                                      • Returns an array of all upserted ids

                                                                                                                      method getWriteConcernError

                                                                                                                      getWriteConcernError: () => WriteConcernError;
                                                                                                                      • Retrieve the write concern error if any

                                                                                                                      method getWriteErrorAt

                                                                                                                      getWriteErrorAt: (index: number) => WriteError;
                                                                                                                      • Returns a specific write error object

                                                                                                                        Parameter index

                                                                                                                        of the write error to return, returns null if there is no result for passed in index

                                                                                                                      method getWriteErrorCount

                                                                                                                      getWriteErrorCount: () => number;
                                                                                                                      • Returns the number of write errors off the bulk operation

                                                                                                                      method getWriteErrors

                                                                                                                      getWriteErrors: () => object[];
                                                                                                                      • Retrieve all write errors

                                                                                                                      method hasWriteErrors

                                                                                                                      hasWriteErrors: () => boolean;
                                                                                                                      • Returns true if the bulk operation contains a write error

                                                                                                                      interface BulkWriteResultUpsertedIdObject

                                                                                                                      interface BulkWriteResultUpsertedIdObject {}
                                                                                                                      • Returning upserted object from bulkWrite operations

                                                                                                                        See Also

                                                                                                                        • https://docs.mongodb.com/v3.6/reference/method/BulkWriteResult/index.html#BulkWriteResult.upserted

                                                                                                                      property index

                                                                                                                      index: number;

                                                                                                                        interface ChangeEventBase

                                                                                                                        interface ChangeEventBase<TSchema extends { [key: string]: any } = DefaultSchema> {}

                                                                                                                          property clusterTime

                                                                                                                          clusterTime: Timestamp;

                                                                                                                            property lsid

                                                                                                                            lsid?: {
                                                                                                                            id: any;
                                                                                                                            uid: any;
                                                                                                                            };

                                                                                                                              property ns

                                                                                                                              ns: {
                                                                                                                              db: string;
                                                                                                                              coll: string;
                                                                                                                              };
                                                                                                                              • We leave this off the base type so that we can differentiate by checking its value and get intelligent types on the other fields

                                                                                                                              property txnNumber

                                                                                                                              txnNumber?: number;

                                                                                                                                interface ChangeEventCR

                                                                                                                                interface ChangeEventCR<TSchema extends { [key: string]: any } = DefaultSchema>
                                                                                                                                extends ChangeEventBase<TSchema> {}

                                                                                                                                  property documentKey

                                                                                                                                  documentKey: {
                                                                                                                                  _id: ExtractIdType<TSchema>;
                                                                                                                                  };

                                                                                                                                    property fullDocument

                                                                                                                                    fullDocument?: TSchema;

                                                                                                                                      property operationType

                                                                                                                                      operationType: 'insert' | 'replace';

                                                                                                                                        interface ChangeEventDelete

                                                                                                                                        interface ChangeEventDelete<TSchema extends { [key: string]: any } = DefaultSchema>
                                                                                                                                        extends ChangeEventBase<TSchema> {}

                                                                                                                                          property documentKey

                                                                                                                                          documentKey: {
                                                                                                                                          _id: ExtractIdType<TSchema>;
                                                                                                                                          };

                                                                                                                                            property operationType

                                                                                                                                            operationType: 'delete';

                                                                                                                                              interface ChangeEventInvalidate

                                                                                                                                              interface ChangeEventInvalidate<
                                                                                                                                              TSchema extends { [key: string]: any } = DefaultSchema
                                                                                                                                              > {}

                                                                                                                                                property clusterTime

                                                                                                                                                clusterTime: Timestamp;

                                                                                                                                                  property operationType

                                                                                                                                                  operationType: 'invalidate';

                                                                                                                                                    interface ChangeEventOther

                                                                                                                                                    interface ChangeEventOther<TSchema extends { [key: string]: any } = DefaultSchema>
                                                                                                                                                    extends ChangeEventBase<TSchema> {}

                                                                                                                                                      property operationType

                                                                                                                                                      operationType: 'drop' | 'dropDatabase';

                                                                                                                                                        interface ChangeEventRename

                                                                                                                                                        interface ChangeEventRename<TSchema extends { [key: string]: any } = DefaultSchema>
                                                                                                                                                        extends ChangeEventBase<TSchema> {}

                                                                                                                                                          property operationType

                                                                                                                                                          operationType: 'rename';

                                                                                                                                                            property to

                                                                                                                                                            to: {
                                                                                                                                                            db: string;
                                                                                                                                                            coll: string;
                                                                                                                                                            };

                                                                                                                                                              interface ChangeEventUpdate

                                                                                                                                                              interface ChangeEventUpdate<TSchema extends { [key: string]: any } = DefaultSchema>
                                                                                                                                                              extends ChangeEventBase<TSchema> {}

                                                                                                                                                                property documentKey

                                                                                                                                                                documentKey: {
                                                                                                                                                                _id: ExtractIdType<TSchema>;
                                                                                                                                                                };

                                                                                                                                                                  property fullDocument

                                                                                                                                                                  fullDocument?: TSchema;

                                                                                                                                                                    property operationType

                                                                                                                                                                    operationType: 'update';

                                                                                                                                                                      property updateDescription

                                                                                                                                                                      updateDescription: {
                                                                                                                                                                      /**
                                                                                                                                                                      * This is an object with all changed fields; if they are nested,
                                                                                                                                                                      * the keys will be paths, e.g. 'question.answer.0.text': 'new text'
                                                                                                                                                                      */
                                                                                                                                                                      updatedFields: FieldUpdates<TSchema>;
                                                                                                                                                                      removedFields: Array<keyof TSchema | string>;
                                                                                                                                                                      };

                                                                                                                                                                        interface ChangeStreamOptions

                                                                                                                                                                        interface ChangeStreamOptions {}
                                                                                                                                                                        • Options that can be passed to a ChangeStream. Note that startAfter, resumeAfter, and startAtOperationTime are all mutually exclusive, and the server will error if more than one is specified.

                                                                                                                                                                          See Also

                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/global.html#ChangeStreamOptions

                                                                                                                                                                        property batchSize

                                                                                                                                                                        batchSize?: number;

                                                                                                                                                                          property collation

                                                                                                                                                                          collation?: CollationDocument;

                                                                                                                                                                            property fullDocument

                                                                                                                                                                            fullDocument?: 'default' | 'updateLookup';

                                                                                                                                                                              property maxAwaitTimeMS

                                                                                                                                                                              maxAwaitTimeMS?: number;

                                                                                                                                                                                property readPreference

                                                                                                                                                                                readPreference?: ReadPreferenceOrMode;

                                                                                                                                                                                  property resumeAfter

                                                                                                                                                                                  resumeAfter?: ResumeToken;

                                                                                                                                                                                    property startAfter

                                                                                                                                                                                    startAfter?: ResumeToken;

                                                                                                                                                                                      property startAtOperationTime

                                                                                                                                                                                      startAtOperationTime?: Timestamp;

                                                                                                                                                                                        interface ClientSession

                                                                                                                                                                                        interface ClientSession extends EventEmitter {}
                                                                                                                                                                                        • A class representing a client session on the server WARNING: not meant to be instantiated directly.

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html

                                                                                                                                                                                        property id

                                                                                                                                                                                        id: ClientSessionId;
                                                                                                                                                                                        • The server id associated with this session

                                                                                                                                                                                        method abortTransaction

                                                                                                                                                                                        abortTransaction: { (): Promise<void>; (callback?: MongoCallback<void>): void };
                                                                                                                                                                                        • Aborts the currently active transaction in this session.

                                                                                                                                                                                          Parameter callback

                                                                                                                                                                                          Optional callback for completion of this operation

                                                                                                                                                                                          Returns

                                                                                                                                                                                          Promise if no callback is provided

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html#abortTransaction

                                                                                                                                                                                        method advanceOperationTime

                                                                                                                                                                                        advanceOperationTime: (operationTime: any) => void;
                                                                                                                                                                                        • Advances the operationTime for a ClientSession.

                                                                                                                                                                                          Parameter operationTime

                                                                                                                                                                                          The BSON.Timestamp of the operation type it is desired to advance to

                                                                                                                                                                                        method commitTransaction

                                                                                                                                                                                        commitTransaction: { (): Promise<void>; (callback: MongoCallback<void>): void };
                                                                                                                                                                                        • Commits the currently active transaction in this session.

                                                                                                                                                                                          Parameter callback

                                                                                                                                                                                          Optional callback for completion of this operation

                                                                                                                                                                                          Returns

                                                                                                                                                                                          Promise if no callback is provided

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html#commitTransaction

                                                                                                                                                                                        method endSession

                                                                                                                                                                                        endSession: {
                                                                                                                                                                                        (callback?: MongoCallback<void>): void;
                                                                                                                                                                                        (options: Object, callback: MongoCallback<void>): void;
                                                                                                                                                                                        (options?: Object): Promise<void>;
                                                                                                                                                                                        };
                                                                                                                                                                                        • Ends this session on the server

                                                                                                                                                                                          Parameter options

                                                                                                                                                                                          Optional settings Currently reserved for future use

                                                                                                                                                                                          Parameter callback

                                                                                                                                                                                          Optional callback for completion of this operation

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html#endSession

                                                                                                                                                                                        method equals

                                                                                                                                                                                        equals: (session: ClientSession) => boolean;
                                                                                                                                                                                        • Used to determine if this session equals another

                                                                                                                                                                                          Parameter session

                                                                                                                                                                                          a class representing a client session on the server

                                                                                                                                                                                          Returns

                                                                                                                                                                                          true if the sessions are equal

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html#equals

                                                                                                                                                                                        method incrementTransactionNumber

                                                                                                                                                                                        incrementTransactionNumber: () => void;
                                                                                                                                                                                        • Increment the transaction number on the internal ServerSession

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html#incrementTransactionNumber

                                                                                                                                                                                        method inTransaction

                                                                                                                                                                                        inTransaction: () => boolean;
                                                                                                                                                                                        • Returns

                                                                                                                                                                                          whether this session is currently in a transaction or not

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html#inTransaction

                                                                                                                                                                                        method startTransaction

                                                                                                                                                                                        startTransaction: (options?: TransactionOptions) => void;
                                                                                                                                                                                        • Starts a new transaction with the given options.

                                                                                                                                                                                          Parameter options

                                                                                                                                                                                          Options for the transaction

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html#startTransaction

                                                                                                                                                                                        method withTransaction

                                                                                                                                                                                        withTransaction: (
                                                                                                                                                                                        fn: WithTransactionCallback,
                                                                                                                                                                                        options?: TransactionOptions
                                                                                                                                                                                        ) => Promise<any>;
                                                                                                                                                                                        • Runs a provided lambda within a transaction, retrying either the commit operation or entire transaction as needed (and when the error permits) to better ensure that the transaction can complete successfully.

                                                                                                                                                                                          IMPORTANT: This method requires the user to return a Promise, all lambdas that do not return a Promise will result in undefined behavior.

                                                                                                                                                                                          Parameter fn

                                                                                                                                                                                          A user provided function to be run within a transaction

                                                                                                                                                                                          Parameter options

                                                                                                                                                                                          Optional settings for the transaction

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://mongodb.github.io/node-mongodb-native/3.6/api/ClientSession.html#withTransaction

                                                                                                                                                                                        interface CollationDocument

                                                                                                                                                                                        interface CollationDocument {}
                                                                                                                                                                                        • Possible fields for a collation document

                                                                                                                                                                                          See Also

                                                                                                                                                                                          • https://docs.mongodb.com/v3.6/reference/collation/#collation-document-fields

                                                                                                                                                                                        property alternate

                                                                                                                                                                                        alternate?: string;

                                                                                                                                                                                          property backwards

                                                                                                                                                                                          backwards?: boolean;

                                                                                                                                                                                            property caseFirst

                                                                                                                                                                                            caseFirst?: string;

                                                                                                                                                                                              property caseLevel

                                                                                                                                                                                              caseLevel?: boolean;

                                                                                                                                                                                                property locale

                                                                                                                                                                                                locale: string;

                                                                                                                                                                                                  property maxVariable

                                                                                                                                                                                                  maxVariable?: string;

                                                                                                                                                                                                    property normalization

                                                                                                                                                                                                    normalization?: boolean;

                                                                                                                                                                                                      property numericOrdering

                                                                                                                                                                                                      numericOrdering?: boolean;

                                                                                                                                                                                                        property strength

                                                                                                                                                                                                        strength?: number;

                                                                                                                                                                                                          interface Collection

                                                                                                                                                                                                          interface Collection<TSchema extends { [key: string]: any } = DefaultSchema> {}
                                                                                                                                                                                                          • Create a new Collection instance (INTERNAL TYPE, do not instantiate directly)

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html

                                                                                                                                                                                                          property collectionName

                                                                                                                                                                                                          collectionName: string;
                                                                                                                                                                                                          • Get the collection name.

                                                                                                                                                                                                          property hint

                                                                                                                                                                                                          hint: any;
                                                                                                                                                                                                          • Get current index hint for collection.

                                                                                                                                                                                                          property namespace

                                                                                                                                                                                                          namespace: string;
                                                                                                                                                                                                          • Get the full collection namespace.

                                                                                                                                                                                                          property readConcern

                                                                                                                                                                                                          readConcern: ReadConcern;
                                                                                                                                                                                                          • The current read concern values.

                                                                                                                                                                                                          property writeConcern

                                                                                                                                                                                                          writeConcern: WriteConcern;
                                                                                                                                                                                                          • The current write concern values.

                                                                                                                                                                                                          method aggregate

                                                                                                                                                                                                          aggregate: {
                                                                                                                                                                                                          <T = TSchema>(
                                                                                                                                                                                                          callback: MongoCallback<AggregationCursor<T>>
                                                                                                                                                                                                          ): AggregationCursor<T>;
                                                                                                                                                                                                          <T = TSchema>(
                                                                                                                                                                                                          pipeline: object[],
                                                                                                                                                                                                          callback: MongoCallback<AggregationCursor<T>>
                                                                                                                                                                                                          ): AggregationCursor<T>;
                                                                                                                                                                                                          <T = TSchema>(
                                                                                                                                                                                                          pipeline?: object[],
                                                                                                                                                                                                          options?: CollectionAggregationOptions,
                                                                                                                                                                                                          callback?: MongoCallback<AggregationCursor<T>>
                                                                                                                                                                                                          ): AggregationCursor<T>;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2

                                                                                                                                                                                                            Parameter pipeline

                                                                                                                                                                                                            Array containing all the aggregation framework commands for the execution

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#aggregate

                                                                                                                                                                                                          method bulkWrite

                                                                                                                                                                                                          bulkWrite: {
                                                                                                                                                                                                          (
                                                                                                                                                                                                          operations: Array<BulkWriteOperation<TSchema>>,
                                                                                                                                                                                                          callback: MongoCallback<BulkWriteOpResultObject>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          operations: BulkWriteOperation<TSchema>[],
                                                                                                                                                                                                          options?: CollectionBulkWriteOptions
                                                                                                                                                                                                          ): Promise<BulkWriteOpResultObject>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          operations: BulkWriteOperation<TSchema>[],
                                                                                                                                                                                                          options: CollectionBulkWriteOptions,
                                                                                                                                                                                                          callback: MongoCallback<BulkWriteOpResultObject>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Perform a bulkWrite operation without a fluent API If documents passed in do not contain the **_id** field, one will be added to each of the documents missing it by the driver, mutating the document. This behavior can be overridden by setting the **forceServerObjectId** flag.

                                                                                                                                                                                                            Parameter operations

                                                                                                                                                                                                            Bulk operations to perform

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#bulkWrite

                                                                                                                                                                                                          method count

                                                                                                                                                                                                          count: {
                                                                                                                                                                                                          (callback: MongoCallback<number>): void;
                                                                                                                                                                                                          (query: FilterQuery<TSchema>, callback: MongoCallback<number>): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          query?: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: MongoCountPreferences
                                                                                                                                                                                                          ): Promise<number>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          query: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: MongoCountPreferences,
                                                                                                                                                                                                          callback: MongoCallback<number>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • An estimated count of matching documents in the db to a query.

                                                                                                                                                                                                            Parameter query

                                                                                                                                                                                                            The query for the count

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#count

                                                                                                                                                                                                            Deprecated

                                                                                                                                                                                                            Use countDocuments or estimatedDocumentCount

                                                                                                                                                                                                          method countDocuments

                                                                                                                                                                                                          countDocuments: {
                                                                                                                                                                                                          (callback: MongoCallback<number>): void;
                                                                                                                                                                                                          (query: FilterQuery<TSchema>, callback: MongoCallback<number>): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          query?: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: MongoCountPreferences
                                                                                                                                                                                                          ): Promise<number>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          query: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: MongoCountPreferences,
                                                                                                                                                                                                          callback: MongoCallback<number>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Gets the number of documents matching the filter For a fast count of the total documents in a collection see estimatedDocumentCount.

                                                                                                                                                                                                            Parameter query

                                                                                                                                                                                                            The query for the count

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#countDocuments

                                                                                                                                                                                                          method createIndex

                                                                                                                                                                                                          createIndex: {
                                                                                                                                                                                                          (fieldOrSpec: string | any, callback: MongoCallback<string>): void;
                                                                                                                                                                                                          (fieldOrSpec: any, options?: IndexOptions): Promise<string>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          fieldOrSpec: any,
                                                                                                                                                                                                          options: IndexOptions,
                                                                                                                                                                                                          callback: MongoCallback<string>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Creates an index on the db and collection collection.

                                                                                                                                                                                                            Parameter fieldOrSpec

                                                                                                                                                                                                            Defines the index

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#createIndex

                                                                                                                                                                                                          method createIndexes

                                                                                                                                                                                                          createIndexes: {
                                                                                                                                                                                                          (indexSpecs: IndexSpecification[], callback: MongoCallback<any>): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          indexSpecs: IndexSpecification[],
                                                                                                                                                                                                          options?: { session?: ClientSession }
                                                                                                                                                                                                          ): Promise<any>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          indexSpecs: IndexSpecification[],
                                                                                                                                                                                                          options: { session?: ClientSession },
                                                                                                                                                                                                          callback: MongoCallback<any>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher. Earlier version of MongoDB will throw a command not supported error. **Note:** Unlike createIndex, this function takes in raw index specifications. Index specifications are defined .

                                                                                                                                                                                                            Parameter indexSpecs

                                                                                                                                                                                                            An array of index specifications to be created

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#createIndexes

                                                                                                                                                                                                          method deleteMany

                                                                                                                                                                                                          deleteMany: {
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          callback: MongoCallback<DeleteWriteOpResultObject>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: CommonOptions
                                                                                                                                                                                                          ): Promise<DeleteWriteOpResultObject>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: CommonOptions,
                                                                                                                                                                                                          callback: MongoCallback<DeleteWriteOpResultObject>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Delete multiple documents from a collection

                                                                                                                                                                                                            Parameter filter

                                                                                                                                                                                                            The Filter used to select the documents to remove

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#deleteMany

                                                                                                                                                                                                          method deleteOne

                                                                                                                                                                                                          deleteOne: {
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          callback: MongoCallback<DeleteWriteOpResultObject>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: CommonOptions & { bypassDocumentValidation?: boolean }
                                                                                                                                                                                                          ): Promise<DeleteWriteOpResultObject>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: CommonOptions & { bypassDocumentValidation?: boolean },
                                                                                                                                                                                                          callback: MongoCallback<DeleteWriteOpResultObject>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Delete a document from a collection

                                                                                                                                                                                                            Parameter filter

                                                                                                                                                                                                            The Filter used to select the document to remove

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#deleteOne

                                                                                                                                                                                                          method distinct

                                                                                                                                                                                                          distinct: {
                                                                                                                                                                                                          <Key extends '_id' | keyof EnhancedOmit<TSchema, '_id'>>(
                                                                                                                                                                                                          key: Key,
                                                                                                                                                                                                          callback: MongoCallback<Array<FlattenIfArray<WithId<TSchema>[Key]>>>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          <Key extends '_id' | keyof EnhancedOmit<TSchema, '_id'>>(
                                                                                                                                                                                                          key: Key,
                                                                                                                                                                                                          query: FilterQuery<TSchema>,
                                                                                                                                                                                                          callback: MongoCallback<FlattenIfArray<WithId<TSchema>[Key]>[]>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          <Key extends '_id' | keyof EnhancedOmit<TSchema, '_id'>>(
                                                                                                                                                                                                          key: Key,
                                                                                                                                                                                                          query?: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: MongoDistinctPreferences
                                                                                                                                                                                                          ): Promise<FlattenIfArray<WithId<TSchema>[Key]>[]>;
                                                                                                                                                                                                          <Key extends '_id' | keyof EnhancedOmit<TSchema, '_id'>>(
                                                                                                                                                                                                          key: Key,
                                                                                                                                                                                                          query: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: MongoDistinctPreferences,
                                                                                                                                                                                                          callback: MongoCallback<FlattenIfArray<WithId<TSchema>[Key]>[]>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          (key: string, callback: MongoCallback<any[]>): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          key: string,
                                                                                                                                                                                                          query: FilterQuery<TSchema>,
                                                                                                                                                                                                          callback: MongoCallback<any[]>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          key: string,
                                                                                                                                                                                                          query?: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: MongoDistinctPreferences
                                                                                                                                                                                                          ): Promise<any[]>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          key: string,
                                                                                                                                                                                                          query: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: MongoDistinctPreferences,
                                                                                                                                                                                                          callback: MongoCallback<any[]>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • The distinct command returns a list of distinct values for the given key across a collection.

                                                                                                                                                                                                            Parameter key

                                                                                                                                                                                                            Field of the document to find distinct values for.

                                                                                                                                                                                                            Parameter query

                                                                                                                                                                                                            The optional query for filtering the set of documents to which we apply the distinct filter.

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#distinct

                                                                                                                                                                                                          method drop

                                                                                                                                                                                                          drop: {
                                                                                                                                                                                                          (options?: { session: ClientSession }): Promise<any>;
                                                                                                                                                                                                          (callback: MongoCallback<any>): void;
                                                                                                                                                                                                          (options: { session: ClientSession }, callback: MongoCallback<any>): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Drop the collection from the database, removing it permanently. New accesses will create a new collection.

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#drop

                                                                                                                                                                                                          method dropIndex

                                                                                                                                                                                                          dropIndex: {
                                                                                                                                                                                                          (indexName: string, callback: MongoCallback<any>): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          indexName: string,
                                                                                                                                                                                                          options?: CommonOptions & { maxTimeMS?: number }
                                                                                                                                                                                                          ): Promise<any>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          indexName: string,
                                                                                                                                                                                                          options: CommonOptions & { maxTimeMS?: number },
                                                                                                                                                                                                          callback: MongoCallback<any>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Drops an index from this collection.

                                                                                                                                                                                                            Parameter indexName

                                                                                                                                                                                                            Name of the index to drop.

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#dropIndex

                                                                                                                                                                                                          method dropIndexes

                                                                                                                                                                                                          dropIndexes: {
                                                                                                                                                                                                          (options?: { session?: ClientSession; maxTimeMS?: number }): Promise<any>;
                                                                                                                                                                                                          (callback?: MongoCallback<any>): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          options: { session?: ClientSession; maxTimeMS?: number },
                                                                                                                                                                                                          callback: MongoCallback<any>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Drops all indexes from this collection.

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#dropIndexes

                                                                                                                                                                                                          method estimatedDocumentCount

                                                                                                                                                                                                          estimatedDocumentCount: {
                                                                                                                                                                                                          (callback: MongoCallback<number>): void;
                                                                                                                                                                                                          (query: FilterQuery<TSchema>, callback: MongoCallback<number>): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          query?: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: MongoCountPreferences
                                                                                                                                                                                                          ): Promise<number>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          query: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: MongoCountPreferences,
                                                                                                                                                                                                          callback: MongoCallback<number>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Gets an estimate of the count of documents in a collection using collection metadata.

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#estimatedDocumentCount

                                                                                                                                                                                                          method find

                                                                                                                                                                                                          find: {
                                                                                                                                                                                                          (query?: FilterQuery<TSchema>): Cursor<TSchema>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          query: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: WithoutProjection<FindOneOptions<TSchema>>
                                                                                                                                                                                                          ): Cursor<TSchema>;
                                                                                                                                                                                                          <T = TSchema>(
                                                                                                                                                                                                          query: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: FindOneOptions<T extends TSchema ? TSchema : T>
                                                                                                                                                                                                          ): Cursor<T>;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Creates a cursor for a query that can be used to iterate over results from MongoDB

                                                                                                                                                                                                            Parameter query

                                                                                                                                                                                                            The cursor query object

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#find

                                                                                                                                                                                                          method findOne

                                                                                                                                                                                                          findOne: {
                                                                                                                                                                                                          (filter: FilterQuery<TSchema>, callback: MongoCallback<TSchema>): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: WithoutProjection<FindOneOptions<TSchema>>
                                                                                                                                                                                                          ): Promise<TSchema>;
                                                                                                                                                                                                          <T = TSchema>(
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: FindOneOptions<T extends TSchema ? TSchema : T>
                                                                                                                                                                                                          ): Promise<T>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: WithoutProjection<FindOneOptions<TSchema>>,
                                                                                                                                                                                                          callback: MongoCallback<TSchema>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          <T = TSchema>(
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: FindOneOptions<T extends TSchema ? TSchema : T>,
                                                                                                                                                                                                          callback: MongoCallback<T extends TSchema ? TSchema : T>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Fetches the first document that matches the query

                                                                                                                                                                                                            Parameter query

                                                                                                                                                                                                            Query for find Operation

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#findOne

                                                                                                                                                                                                          method findOneAndDelete

                                                                                                                                                                                                          findOneAndDelete: {
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options?: FindOneAndDeleteOption<TSchema>
                                                                                                                                                                                                          ): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          options: FindOneAndDeleteOption<TSchema>,
                                                                                                                                                                                                          callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Find a document and delete it in one atomic operation. Requires a write lock for the duration of the operation.

                                                                                                                                                                                                            Parameter filter

                                                                                                                                                                                                            The Filter used to select the document to remove

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#findOneAndDelete

                                                                                                                                                                                                          method findOneAndReplace

                                                                                                                                                                                                          findOneAndReplace: {
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          replacement: object,
                                                                                                                                                                                                          callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          replacement: object,
                                                                                                                                                                                                          options?: FindOneAndReplaceOption<TSchema>
                                                                                                                                                                                                          ): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          replacement: object,
                                                                                                                                                                                                          options: FindOneAndReplaceOption<TSchema>,
                                                                                                                                                                                                          callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Find a document and replace it in one atomic operation. Requires a write lock for the duration of the operation.

                                                                                                                                                                                                            Parameter filter

                                                                                                                                                                                                            The Filter used to select the document to replace

                                                                                                                                                                                                            Parameter replacement

                                                                                                                                                                                                            The Document that replaces the matching document

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#findOneAndReplace

                                                                                                                                                                                                          method findOneAndUpdate

                                                                                                                                                                                                          findOneAndUpdate: {
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          update: UpdateQuery<TSchema> | TSchema,
                                                                                                                                                                                                          callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          update: TSchema | UpdateQuery<TSchema>,
                                                                                                                                                                                                          options?: FindOneAndUpdateOption<TSchema>
                                                                                                                                                                                                          ): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          filter: FilterQuery<TSchema>,
                                                                                                                                                                                                          update: TSchema | UpdateQuery<TSchema>,
                                                                                                                                                                                                          options: FindOneAndUpdateOption<TSchema>,
                                                                                                                                                                                                          callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Find a document and update it in one atomic operation. Requires a write lock for the duration of the operation.

                                                                                                                                                                                                            Parameter filter

                                                                                                                                                                                                            The Filter used to select the document to update

                                                                                                                                                                                                            Parameter update

                                                                                                                                                                                                            Update operations to be performed on the document

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#findOneAndUpdate

                                                                                                                                                                                                          method geoHaystackSearch

                                                                                                                                                                                                          geoHaystackSearch: {
                                                                                                                                                                                                          (x: number, y: number, callback: MongoCallback<any>): void;
                                                                                                                                                                                                          (x: number, y: number, options?: GeoHaystackSearchOptions): Promise<any>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          x: number,
                                                                                                                                                                                                          y: number,
                                                                                                                                                                                                          options: GeoHaystackSearchOptions,
                                                                                                                                                                                                          callback: MongoCallback<any>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Execute a geo search using a geo haystack index on a collection.

                                                                                                                                                                                                            Parameter x

                                                                                                                                                                                                            Point to search on the x axis, ensure the indexes are ordered in the same order.

                                                                                                                                                                                                            Parameter y

                                                                                                                                                                                                            Point to search on the y axis, ensure the indexes are ordered in the same order.

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#geoHaystackSearch

                                                                                                                                                                                                            Deprecated

                                                                                                                                                                                                            See for current geospatial support

                                                                                                                                                                                                          method group

                                                                                                                                                                                                          group: {
                                                                                                                                                                                                          (
                                                                                                                                                                                                          keys: object | any[] | Function | Code,
                                                                                                                                                                                                          condition: object,
                                                                                                                                                                                                          initial: object,
                                                                                                                                                                                                          reduce: Function | Code,
                                                                                                                                                                                                          finalize: Function | Code,
                                                                                                                                                                                                          command: boolean,
                                                                                                                                                                                                          callback: MongoCallback<any>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          keys: object | Function | any[] | Code,
                                                                                                                                                                                                          condition: object,
                                                                                                                                                                                                          initial: object,
                                                                                                                                                                                                          reduce: Function | Code,
                                                                                                                                                                                                          finalize: Function | Code,
                                                                                                                                                                                                          command: boolean,
                                                                                                                                                                                                          options?: {
                                                                                                                                                                                                          readPreference?: ReadPreferenceOrMode;
                                                                                                                                                                                                          session?: ClientSession;
                                                                                                                                                                                                          }
                                                                                                                                                                                                          ): Promise<any>;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          keys: object | Function | any[] | Code,
                                                                                                                                                                                                          condition: object,
                                                                                                                                                                                                          initial: object,
                                                                                                                                                                                                          reduce: Function | Code,
                                                                                                                                                                                                          finalize: Function | Code,
                                                                                                                                                                                                          command: boolean,
                                                                                                                                                                                                          options: {
                                                                                                                                                                                                          readPreference?: ReadPreferenceOrMode;
                                                                                                                                                                                                          session?: ClientSession;
                                                                                                                                                                                                          },
                                                                                                                                                                                                          callback: MongoCallback<any>
                                                                                                                                                                                                          ): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Run a group command across a collection

                                                                                                                                                                                                            Parameter keys

                                                                                                                                                                                                            An object, array or function expressing the keys to group by.

                                                                                                                                                                                                            Parameter condition

                                                                                                                                                                                                            An optional condition that must be true for a row to be considered.

                                                                                                                                                                                                            Parameter initial

                                                                                                                                                                                                            Initial value of the aggregation counter object.

                                                                                                                                                                                                            Parameter reduce

                                                                                                                                                                                                            The reduce function aggregates (reduces) the objects iterated.

                                                                                                                                                                                                            Parameter finalize

                                                                                                                                                                                                            An optional function to be run on each item in the result set just before the item is returned.

                                                                                                                                                                                                            Parameter command

                                                                                                                                                                                                            Specify if you wish to run using the internal group command or using eval, default is true.

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#group

                                                                                                                                                                                                            Deprecated

                                                                                                                                                                                                            MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework.

                                                                                                                                                                                                          method indexes

                                                                                                                                                                                                          indexes: {
                                                                                                                                                                                                          (options?: { session: ClientSession }): Promise<any>;
                                                                                                                                                                                                          (callback: MongoCallback<any>): void;
                                                                                                                                                                                                          (options: { session?: ClientSession }, callback: MongoCallback<any>): void;
                                                                                                                                                                                                          };
                                                                                                                                                                                                          • Retrieve all the indexes on the collection.

                                                                                                                                                                                                            Parameter options

                                                                                                                                                                                                            Optional settings

                                                                                                                                                                                                            Parameter callback

                                                                                                                                                                                                            The command result callback

                                                                                                                                                                                                            Returns

                                                                                                                                                                                                            Promise if no callback is passed

                                                                                                                                                                                                            See Also

                                                                                                                                                                                                            • https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#indexes

                                                                                                                                                                                                          method indexExists

                                                                                                                                                                                                          indexExists: {
                                                                                                                                                                                                          (indexes: string | string[], callback: MongoCallback<boolean>): void;
                                                                                                                                                                                                          (
                                                                                                                                                                                                          indexes: string | string[],
                                                                                                                                                                                                          options