Options
All
  • Public
  • Public/Protected
  • All
Menu

mongodb

Index

Error Classes

Event Classes

Other Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

AbstractCursorEvents

AbstractCursorEvents: { close: any }

Type declaration

AcceptedFields

AcceptedFields<TSchema, FieldType, AssignableType>: {readonly [ key in KeysOfAType<TSchema, FieldType>]?: AssignableType }

Type parameters

  • TSchema

  • FieldType

  • AssignableType

AddToSetOperators

AddToSetOperators<Type>: { $each?: Flatten<Type>[] }

Type parameters

  • Type

Type declaration

AlternativeType

AlternativeType<T>: T extends ReadonlyArray<infer U> ? T | RegExpOrString<U> : RegExpOrString<T>

It is possible to search using alternative types in mongodb e.g. string types can be searched using a regex in mongo array types can be searched using their element type

Type parameters

  • T

AnyBulkWriteOperation

AnyBulkWriteOperation<TSchema>: { insertOne: InsertOneModel<TSchema> } | { replaceOne: ReplaceOneModel<TSchema> } | { updateOne: UpdateOneModel<TSchema> } | { updateMany: UpdateManyModel<TSchema> } | { deleteOne: DeleteOneModel<TSchema> } | { deleteMany: DeleteManyModel<TSchema> }

Type parameters

AnyError

AnyError: MongoError | Error

ArrayOperator

ArrayOperator<Type>: { $each?: Flatten<Type>[]; $position?: number; $slice?: number; $sort?: Sort }

Type parameters

  • Type

Type declaration

  • Optional $each?: Flatten<Type>[]
  • Optional $position?: number
  • Optional $slice?: number
  • Optional $sort?: Sort

AuthMechanism

AuthMechanism: typeof AuthMechanism[keyof typeof AuthMechanism]

AutoEncryptionLoggerLevel

AutoEncryptionLoggerLevel: typeof AutoEncryptionLoggerLevel[keyof typeof AutoEncryptionLoggerLevel]

BSONType

BSONType: typeof BSONType[keyof typeof BSONType]

BSONTypeAlias

BSONTypeAlias: keyof typeof BSONType

BatchType

BatchType: typeof BatchType[keyof typeof BatchType]

BitwiseFilter

BitwiseFilter: number | Binary | ReadonlyArray<number>

Callback

Callback<T>: (error?: AnyError, result?: T) => void

Type parameters

  • T = any

Type declaration

    • MongoDB Driver style callback

      Parameters

      • Optional error: AnyError
      • Optional result: T

      Returns void

ChangeStreamEvents

ChangeStreamEvents: { change: any; end: any; error: any; init: any; more: any; response: any; resumeTokenChanged: any } & AbstractCursorEvents

ClientSessionEvents

ClientSessionEvents: { ended: any }

Type declaration

CommonEvents

CommonEvents: "newListener" | "removeListener"

Compressor

Compressor: typeof Compressor[CompressorName]

CompressorName

CompressorName: keyof typeof Compressor

Condition

Type parameters

  • T

ConnectionEvents

ConnectionEvents: { close: any; clusterTimeReceived: any; commandFailed: any; commandStarted: any; commandSucceeded: any; message: any; pinned: any; unpinned: any }

Type declaration

ConnectionPoolEvents

ConnectionPoolEvents: { connectionCheckOutFailed: any; connectionCheckOutStarted: any; connectionCheckedIn: any; connectionCheckedOut: any; connectionClosed: any; connectionCreated: any; connectionPoolCleared: any; connectionPoolClosed: any; connectionPoolCreated: any; connectionReady: any } & Omit<ConnectionEvents, "close" | "message">

CursorFlag

CursorFlag: typeof CURSOR_FLAGS[number]

DistinctOptions

DistinctOptions: CommandOperationOptions

DropCollectionOptions

DropCollectionOptions: CommandOperationOptions

DropDatabaseOptions

DropDatabaseOptions: CommandOperationOptions

DropIndexesOptions

DropIndexesOptions: CommandOperationOptions

EnhancedOmit

EnhancedOmit<TRecordOrUnion, KeyUnion>: string extends keyof TRecordOrUnion ? TRecordOrUnion : TRecordOrUnion extends any ? Pick<TRecordOrUnion, Exclude<keyof TRecordOrUnion, KeyUnion>> : never

TypeScript Omit (Exclude to be specific) does not work for objects with an "any" indexed type, and breaks discriminated unions @public

Type parameters

  • TRecordOrUnion

  • KeyUnion

EventEmitterWithState

EventEmitterWithState: { stateChanged: any }

Type declaration

  • stateChanged: function
    • stateChanged(previous: string, current: string): void
    • internal

      Parameters

      • previous: string
      • current: string

      Returns void

EventsDescription

EventsDescription: Record<string, GenericListener>

Event description type

ExplainVerbosity

ExplainVerbosity: string

ExplainVerbosityLike

ExplainVerbosityLike: ExplainVerbosity | boolean

For backwards compatibility, true is interpreted as "allPlansExecution" and false as "queryPlanner". Prior to server version 3.6, aggregate() ignores the verbosity parameter and executes in "queryPlanner".

Filter

Filter<TSchema>: {[ P in keyof TSchema]: Condition<TSchema[P]> } & RootFilterOperators<TSchema>

A MongoDB filter can be some portion of the schema or a set of operators @public

Type parameters

  • TSchema

FilterOperations

FilterOperations<T>: T extends Record<string, any> ? {[ key in keyof T]: FilterOperators<T[key]> } : FilterOperators<T>

Type parameters

  • T

FinalizeFunction

FinalizeFunction<TKey, TValue>: (key: TKey, reducedValue: TValue) => TValue

Type parameters

Type declaration

    • (key: TKey, reducedValue: TValue): TValue
    • Parameters

      • key: TKey
      • reducedValue: TValue

      Returns TValue

Flatten

Flatten<Type>: Type extends ReadonlyArray<infer Item> ? Item : Type

Type parameters

  • Type

GenericListener

GenericListener: (...args: any[]) => void

Type declaration

    • (...args: any[]): void
    • Parameters

      • Rest ...args: any[]

      Returns void

GridFSBucketEvents

GridFSBucketEvents: { index: any }

Type declaration

Hint

Hint: string | Document

IndexDirection

IndexDirection: -1 | 1 | "2d" | "2dsphere" | "text" | "geoHaystack" | number

IndexSpecification

IndexSpecification: OneOrMore<string | [string, IndexDirection] | {} | [string, IndexDirection][] | {}[]>

InferIdType

InferIdType<TSchema>: TSchema extends { _id: infer IdType } ? {} extends IdType ? Exclude<IdType, {}> : unknown extends IdType ? ObjectId : IdType : ObjectId

Given an object shaped type, return the type of the _id field or default to ObjectId @public

Type parameters

  • TSchema

IntegerType

IntegerType: number | Int32 | Long

InternalAbstractCursorOptions

InternalAbstractCursorOptions: Omit<AbstractCursorOptions, "readPreference"> & { exhaust?: boolean; oplogReplay?: boolean; partial?: boolean; readConcern?: ReadConcern; readPreference: ReadPreference }
internal

IsAny

IsAny<Type, ResultIfAny, ResultIfNotAny>: true extends false & Type ? ResultIfAny : ResultIfNotAny

Type parameters

  • Type

  • ResultIfAny

  • ResultIfNotAny

KeysOfAType

KeysOfAType<TSchema, Type>: {[ key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? key : never }[keyof TSchema]

Type parameters

  • TSchema

  • Type

KeysOfOtherType

KeysOfOtherType<TSchema, Type>: {[ key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? never : key }[keyof TSchema]

Type parameters

  • TSchema

  • Type

ListDatabasesResult

ListDatabasesResult: string[] | Document[]

LoggerFunction

LoggerFunction: (message?: any, ...optionalParams: any[]) => void

Type declaration

    • (message?: any, ...optionalParams: any[]): void
    • Parameters

      • Optional message: any
      • Rest ...optionalParams: any[]

      Returns void

LoggerLevel

LoggerLevel: typeof LoggerLevel[keyof typeof LoggerLevel]

MapFunction

MapFunction<TSchema>: (this: TSchema) => void

Type parameters

Type declaration

    • (this: TSchema): void
    • Parameters

      • this: TSchema

      Returns void

MatchKeysAndValues

MatchKeysAndValues<TSchema>: Readonly<Partial<TSchema>> & Record<string, any>

Type parameters

  • TSchema

MongoClientEvents

MongoClientEvents: Pick<TopologyEvents, typeof MONGO_CLIENT_EVENTS[number]> & { open: any }

MonitorEvents

MonitorEvents: { close: any; resetConnectionPool: any; resetServer: any; serverHeartbeatFailed: any; serverHeartbeatStarted: any; serverHeartbeatSucceeded: any } & EventEmitterWithState

NotAcceptedFields

NotAcceptedFields<TSchema, FieldType>: {readonly [ key in KeysOfOtherType<TSchema, FieldType>]?: never }

It avoids using fields with not acceptable types @public

Type parameters

  • TSchema

  • FieldType

NumericType

NumericType: IntegerType | Decimal128 | Double

OneOrMore

OneOrMore<T>: T | ReadonlyArray<T>

Type parameters

  • T

OnlyFieldsOfType

OnlyFieldsOfType<TSchema, FieldType, AssignableType>: IsAny<TSchema[keyof TSchema], Record<string, FieldType>, AcceptedFields<TSchema, FieldType, AssignableType> & NotAcceptedFields<TSchema, FieldType> & Record<string, AssignableType>>

Type parameters

  • TSchema

  • FieldType = any

  • AssignableType = FieldType

OperationTime

OperationTime: Timestamp

Represents a specific point in time on a server. Can be retrieved by using {@link Db#command}

remarks

See Run Command Response

OptionalId

OptionalId<TSchema>: ObjectId extends TSchema["_id"] ? EnhancedOmit<TSchema, "_id"> & { _id?: InferIdType<TSchema> } : WithId<TSchema>

Add an optional _id field to an object shaped type

privateremarks

ObjectId extends TSchema['_id'] is a confusing ordering at first glance. Rather than ask TSchema['_id'] extends ObjectId which translated to "Is the _id property ObjectId?" we instead ask "Does ObjectId look like (have the same shape) as the _id?"

Type parameters

  • TSchema: { _id?: any }

ProfilingLevel

ProfilingLevel: typeof ProfilingLevel[keyof typeof ProfilingLevel]

ProfilingLevelOptions

ProfilingLevelOptions: CommandOperationOptions

Projection

Projection<TSchema>: Document
deprecated

since v4.1.0: Since projections support all aggregation operations we have no plans to narrow this type further

Type parameters

ProjectionOperators

ProjectionOperators: Document
deprecated

since v4.1.0: Since projections support all aggregation operations we have no plans to narrow this type further

PullAllOperator

PullAllOperator<TSchema>: {readonly [ key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: TSchema[key] } & NotAcceptedFields<TSchema, ReadonlyArray<any>> & {}

Type parameters

  • TSchema

PullOperator

PullOperator<TSchema>: {readonly [ key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: Partial<Flatten<TSchema[key]>> | FilterOperations<Flatten<TSchema[key]>> } & NotAcceptedFields<TSchema, ReadonlyArray<any>> & {}

Type parameters

  • TSchema

PushOperator

PushOperator<TSchema>: {readonly [ key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: Flatten<TSchema[key]> | ArrayOperator<Flatten<TSchema[key]>[]> } & NotAcceptedFields<TSchema, ReadonlyArray<any>> & {}

Type parameters

  • TSchema

ReadConcernLevel

ReadConcernLevel: typeof ReadConcernLevel[keyof typeof ReadConcernLevel]

ReadConcernLike

ReadConcernLike: ReadConcern | { level: ReadConcernLevel } | ReadConcernLevel

ReadPreferenceLike

ReadPreferenceLike: ReadPreference | ReadPreferenceMode

ReadPreferenceMode

ReadPreferenceMode: typeof ReadPreferenceMode[keyof typeof ReadPreferenceMode]

ReduceFunction

ReduceFunction<TKey, TValue>: (key: TKey, values: TValue[]) => TValue

Type parameters

Type declaration

    • (key: TKey, values: TValue[]): TValue
    • Parameters

      • key: TKey
      • values: TValue[]

      Returns TValue

RegExpOrString

RegExpOrString<T>: T extends string ? BSONRegExp | RegExp | T : T

Type parameters

  • T

RemoveUserOptions

RemoveUserOptions: CommandOperationOptions

ResumeToken

ResumeToken: unknown

Represents the logical starting point for a new or resuming Change Stream on the server.

ReturnDocument

ReturnDocument: typeof ReturnDocument[keyof typeof ReturnDocument]

RunCommandOptions

RunCommandOptions: CommandOperationOptions

SchemaMember

SchemaMember<T, V>: {[ P in keyof T]: V } | {}

Type parameters

  • T

  • V

ServerApiVersion

ServerApiVersion: typeof ServerApiVersion[keyof typeof ServerApiVersion]

ServerEvents

ServerEvents: { closed: any; connect: any; descriptionReceived: any; ended: any; serverHeartbeatFailed: any; serverHeartbeatStarted: any; serverHeartbeatSucceeded: any } & ConnectionPoolEvents & EventEmitterWithState

ServerOptions

ServerOptions: Omit<ConnectionPoolOptions, "id" | "generation" | "hostAddress"> & MonitorOptions

ServerSelectionCallback

ServerSelectionCallback: Callback<Server>
internal

ServerSelector

ServerSelector: (topologyDescription: TopologyDescription, servers: ServerDescription[]) => ServerDescription[]

Type declaration

ServerSessionId

ServerSessionId: { id: Binary }

Type declaration

ServerType

ServerType: typeof ServerType[keyof typeof ServerType]

SetFields

SetFields<TSchema>: {readonly [ key in KeysOfAType<TSchema, ReadonlyArray<any> | undefined>]?: OptionalId<Flatten<TSchema[key]>> | AddToSetOperators<OptionalId<Flatten<TSchema[key]>>[]> } & NotAcceptedFields<TSchema, ReadonlyArray<any> | undefined> & {}

Type parameters

  • TSchema

SetProfilingLevelOptions

SetProfilingLevelOptions: CommandOperationOptions

Sort

Sort: string | Exclude<SortDirection, { $meta: string }> | string[] | {} | Map<string, SortDirection> | [string, SortDirection][] | [string, SortDirection]

SortDirection

SortDirection: 1 | -1 | "asc" | "desc" | "ascending" | "descending" | { $meta: string }

SortDirectionForCmd

SortDirectionForCmd: 1 | -1 | { $meta: string }
internal

SortForCmd

SortForCmd: Map<string, SortDirectionForCmd>
internal

SrvPollerEvents

SrvPollerEvents: { srvRecordDiscovery: any }
internal

Type declaration

Stream

Stream: Socket | TLSSocket

SupportedNodeConnectionOptions

SupportedSocketOptions

SupportedSocketOptions: Pick<TcpNetConnectOpts, typeof LEGAL_TCP_SOCKET_OPTIONS[number]>

SupportedTLSConnectionOptions

SupportedTLSConnectionOptions: Pick<TLSConnectionOptions, Extract<keyof TLSConnectionOptions, typeof LEGAL_TLS_SOCKET_OPTIONS[number]>>

SupportedTLSSocketOptions

SupportedTLSSocketOptions: Pick<TLSSocketOptions, Extract<keyof TLSSocketOptions, typeof LEGAL_TLS_SOCKET_OPTIONS[number]>>

TagSet

TagSet: {}

Type declaration

  • [key: string]: string

TimerQueue

TimerQueue: Set<NodeJS.Timeout>
internal

TopologyEvents

TopologyEvents: { close: any; connect: any; error: any; open: any; serverClosed: any; serverDescriptionChanged: any; serverOpening: any; timeout: any; topologyClosed: any; topologyDescriptionChanged: any; topologyOpening: any } & Omit<ServerEvents, "connect"> & ConnectionPoolEvents & ConnectionEvents & EventEmitterWithState

TopologyType

TopologyType: typeof TopologyType[keyof typeof TopologyType]

TxnState

TxnState: typeof TxnState[keyof typeof TxnState]
internal

UpdateFilter

UpdateFilter<TSchema>: { $addToSet?: SetFields<TSchema>; $bit?: OnlyFieldsOfType<TSchema, NumericType | undefined, { and: IntegerType } | { or: IntegerType } | { xor: IntegerType }>; $currentDate?: OnlyFieldsOfType<TSchema, Date | Timestamp, true | { $type: "date" | "timestamp" }>; $inc?: OnlyFieldsOfType<TSchema, NumericType | undefined>; $max?: MatchKeysAndValues<TSchema>; $min?: MatchKeysAndValues<TSchema>; $mul?: OnlyFieldsOfType<TSchema, NumericType | undefined>; $pop?: OnlyFieldsOfType<TSchema, ReadonlyArray<any>, 1 | -1>; $pull?: PullOperator<TSchema>; $pullAll?: PullAllOperator<TSchema>; $push?: PushOperator<TSchema>; $rename?: Record<string, string>; $set?: MatchKeysAndValues<TSchema>; $setOnInsert?: MatchKeysAndValues<TSchema>; $unset?: OnlyFieldsOfType<TSchema, any, "" | true | 1> } & Document

Type parameters

  • TSchema

W

W: number | "majority"

WithConnectionCallback

WithConnectionCallback: (error: MongoError | undefined, connection: Connection | undefined, callback: Callback<Connection>) => void

Type declaration

    • A callback provided to withConnection

      Parameters

      • error: MongoError | undefined

        An error instance representing the error during the execution.

      • connection: Connection | undefined

        The managed connection which was checked out of the pool.

      • callback: Callback<Connection>

        A function to call back after connection management is complete

      Returns void

WithId

WithId<TSchema>: EnhancedOmit<TSchema, "_id"> & { _id: InferIdType<TSchema> }

Add an _id field to an object shaped type @public

Type parameters

  • TSchema

WithSessionCallback

WithSessionCallback: (session: ClientSession) => Promise<any> | void

Type declaration

WithTransactionCallback

WithTransactionCallback<T>: (session: ClientSession) => Promise<T>

Type parameters

  • T = void

Type declaration

WithoutId

WithoutId<TSchema>: Omit<TSchema, "_id">

Remove the _id field from an object shaped type @public

Type parameters

  • TSchema

WriteProtocolMessageType

WriteProtocolMessageType: Query | Msg | GetMore | KillCursor
internal

Variables

Const AuthMechanism

AuthMechanism: Readonly<{ MONGODB_AWS: "MONGODB-AWS"; MONGODB_CR: "MONGODB-CR"; MONGODB_DEFAULT: "DEFAULT"; MONGODB_GSSAPI: "GSSAPI"; MONGODB_PLAIN: "PLAIN"; MONGODB_SCRAM_SHA1: "SCRAM-SHA-1"; MONGODB_SCRAM_SHA256: "SCRAM-SHA-256"; MONGODB_X509: "MONGODB-X509" }> = ...

Const AutoEncryptionLoggerLevel

AutoEncryptionLoggerLevel: Readonly<{ Error: 1; FatalError: 0; Info: 3; Trace: 4; Warning: 2 }> = ...

Const BSONType

BSONType: Readonly<{ array: 4; binData: 5; bool: 8; date: 9; dbPointer: 12; decimal: 19; double: 1; int: 16; javascript: 13; javascriptWithScope: 15; long: 18; maxKey: 127; minKey: -1; null: 10; object: 3; objectId: 7; regex: 11; string: 2; symbol: 14; timestamp: 17; undefined: 6 }> = ...

Const BatchType

BatchType: Readonly<{ DELETE: 3; INSERT: 1; UPDATE: 2 }> = ...

Const CURSOR_FLAGS

CURSOR_FLAGS: readonly ["tailable", "oplogReplay", "noCursorTimeout", "awaitData", "exhaust", "partial"] = ...

Const Compressor

Compressor: Readonly<{ none: 0; snappy: 1; zlib: 2 }> = ...

Const DB_AGGREGATE_COLLECTION

DB_AGGREGATE_COLLECTION: 1 = ...
internal

Const ExplainVerbosity

ExplainVerbosity: Readonly<{ allPlansExecution: "allPlansExecution"; executionStats: "executionStats"; queryPlanner: "queryPlanner"; queryPlannerExtended: "queryPlannerExtended" }> = ...

Const LEGAL_TCP_SOCKET_OPTIONS

LEGAL_TCP_SOCKET_OPTIONS: readonly ["family", "hints", "localAddress", "localPort", "lookup"] = ...

Const LEGAL_TLS_SOCKET_OPTIONS

LEGAL_TLS_SOCKET_OPTIONS: readonly ["ALPNProtocols", "ca", "cert", "checkServerIdentity", "ciphers", "crl", "ecdhCurve", "key", "minDHSize", "passphrase", "pfx", "rejectUnauthorized", "secureContext", "secureProtocol", "servername", "session"] = ...

Const LoggerLevel

LoggerLevel: Readonly<{ DEBUG: "debug"; ERROR: "error"; INFO: "info"; WARN: "warn"; debug: "debug"; error: "error"; info: "info"; warn: "warn" }> = ...

Const MONGO_CLIENT_EVENTS

MONGO_CLIENT_EVENTS: readonly ["connectionPoolCreated", "connectionPoolClosed", "connectionCreated", "connectionReady", "connectionClosed", "connectionCheckOutStarted", "connectionCheckOutFailed", "connectionCheckedOut", "connectionCheckedIn", "connectionPoolCleared", "close" | "commandStarted" | "commandSucceeded" | "commandFailed" | "serverHeartbeatStarted" | "serverHeartbeatSucceeded" | "serverHeartbeatFailed" | "serverOpening" | "serverClosed" | "serverDescriptionChanged" | "topologyOpening" | "topologyClosed" | "topologyDescriptionChanged" | "error" | "timeout"] = ...

Let Map

Map: MapConstructor

Const ProfilingLevel

ProfilingLevel: Readonly<{ all: "all"; off: "off"; slowOnly: "slow_only" }> = ...

Const ReadConcernLevel

ReadConcernLevel: Readonly<{ available: "available"; linearizable: "linearizable"; local: "local"; majority: "majority"; snapshot: "snapshot" }> = ...

Const ReadPreferenceMode

ReadPreferenceMode: Readonly<{ nearest: "nearest"; primary: "primary"; primaryPreferred: "primaryPreferred"; secondary: "secondary"; secondaryPreferred: "secondaryPreferred" }> = ...

Const ReturnDocument

ReturnDocument: Readonly<{ AFTER: "after"; BEFORE: "before" }> = ...

Const ServerApiVersion

ServerApiVersion: Readonly<{ v1: "1" }> = ...

Const ServerType

ServerType: Readonly<{ LoadBalancer: "LoadBalancer"; Mongos: "Mongos"; PossiblePrimary: "PossiblePrimary"; RSArbiter: "RSArbiter"; RSGhost: "RSGhost"; RSOther: "RSOther"; RSPrimary: "RSPrimary"; RSSecondary: "RSSecondary"; Standalone: "Standalone"; Unknown: "Unknown" }> = ...

An enumeration of server types we know about

Const TopologyType

TopologyType: Readonly<{ LoadBalanced: "LoadBalanced"; ReplicaSetNoPrimary: "ReplicaSetNoPrimary"; ReplicaSetWithPrimary: "ReplicaSetWithPrimary"; Sharded: "Sharded"; Single: "Single"; Unknown: "Unknown" }> = ...

An enumeration of topology types we know about

Const TxnState

TxnState: Readonly<{ NO_TRANSACTION: "NO_TRANSACTION"; STARTING_TRANSACTION: "STARTING_TRANSACTION"; TRANSACTION_ABORTED: "TRANSACTION_ABORTED"; TRANSACTION_COMMITTED: "TRANSACTION_COMMITTED"; TRANSACTION_COMMITTED_EMPTY: "TRANSACTION_COMMITTED_EMPTY"; TRANSACTION_IN_PROGRESS: "TRANSACTION_IN_PROGRESS" }> = ...
internal

Functions

Const deserialize

  • deserialize(buffer: Buffer | ArrayBufferView | ArrayBuffer, options?: DeserializeOptions): Document
  • internal

    Parameters

    • buffer: Buffer | ArrayBufferView | ArrayBuffer
    • Optional options: DeserializeOptions

    Returns Document

Const serialize

  • serialize(object: Document, options?: SerializeOptions): Buffer
  • internal

    Parameters

    • object: Document
    • Optional options: SerializeOptions

    Returns Buffer

Generated using TypeDoc