Options
All
  • Public
  • Public/Protected
  • All
Menu

mongodb

Index

Classes BSONType

Classes Error

Classes Event

Classes Other

Interfaces

Type aliases

Variables

Type aliases

AbstractCursorEvents: { close: any }

Type declaration

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

Type parameters

  • TSchema

  • FieldType

  • AssignableType

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

Type parameters

  • Type

Type declaration

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<TSchema>: { insertOne: InsertOneModel<TSchema> } | { replaceOne: ReplaceOneModel<TSchema> } | { updateOne: UpdateOneModel<TSchema> } | { updateMany: UpdateManyModel<TSchema> } | { deleteOne: DeleteOneModel<TSchema> } | { deleteMany: DeleteManyModel<TSchema> }

Type parameters

AnyError: MongoError | Error
ArrayElement<Type>: Type extends ReadonlyArray<infer Item> ? Item : never

Type parameters

  • Type

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: typeof AuthMechanism[keyof typeof AuthMechanism]
AutoEncryptionLoggerLevel: typeof AutoEncryptionLoggerLevel[keyof typeof AutoEncryptionLoggerLevel]
BSONType: typeof BSONType[keyof typeof BSONType]
BSONTypeAlias: keyof typeof BSONType
BatchType: typeof BatchType[keyof typeof BatchType]
BitwiseFilter: number | Binary | ReadonlyArray<number>
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

Type parameters

ChangeStreamEvents<TSchema, TChange>: { change: any; end: any; error: any; init: any; more: any; response: any; resumeTokenChanged: any } & AbstractCursorEvents

Type parameters

ClientSessionEvents: { ended: any }

Type declaration

CommonEvents: "newListener" | "removeListener"
Compressor: typeof Compressor[CompressorName]
CompressorName: keyof typeof Compressor

Type parameters

  • T

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

Type declaration

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: typeof CURSOR_FLAGS[number]
DistinctOptions: CommandOperationOptions
DropDatabaseOptions: CommandOperationOptions
DropIndexesOptions: CommandOperationOptions
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: { }

Type declaration

    EventsDescription: Record<string, GenericListener>

    Event description type

    ExplainVerbosity: string
    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<TSchema>: Partial<TSchema> | ({ [ Property in Join<NestedPaths<WithId<TSchema>>, ".">]?: Condition<PropertyType<WithId<TSchema>, Property>> } & RootFilterOperators<WithId<TSchema>>)

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

    Type parameters

    • TSchema

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

    Type parameters

    • T

    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<Type>: Type extends ReadonlyArray<infer Item> ? Item : Type

    Type parameters

    • Type

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

    Type declaration

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

        • Rest ...args: any[]

        Returns void

    GridFSBucketEvents: { index: any }

    Type declaration

    Hint: string | Document
    IndexDirection: -1 | 1 | "2d" | "2dsphere" | "text" | "geoHaystack" | number
    IndexSpecification: OneOrMore<string | [string, IndexDirection] | {} | [string, IndexDirection][] | {}[]>
    InferIdType<TSchema>: TSchema extends { _id: infer IdType } ? Record<any, never> extends IdType ? never : IdType : TSchema extends { _id?: infer 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: number | Int32 | Long
    IsAny<Type, ResultIfAny, ResultIfNotAny>: true extends false & Type ? ResultIfAny : ResultIfNotAny

    Type parameters

    • Type

    • ResultIfAny

    • ResultIfNotAny

    Join<T, D>: T extends [] ? "" : T extends [string | number] ? `${T[0]}` : T extends [string | number, ...infer R] ? `${T[0]}${D}${Join<R, D>}` : string

    Type parameters

    • T: unknown[]

    • D: string

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

    Type parameters

    • TSchema

    • Type

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

    Type parameters

    • TSchema

    • Type

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

    Type declaration

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

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

        Returns void

    LoggerLevel: typeof LoggerLevel[keyof typeof LoggerLevel]
    MapFunction<TSchema>: (this: TSchema) => void

    Type parameters

    Type declaration

      • (this: TSchema): void
      • Parameters

        • this: TSchema

        Returns void

    MatchKeysAndValues<TSchema>: Readonly<{ [ Property in Join<NestedPaths<TSchema>, ".">]?: PropertyType<TSchema, Property> } & { [ Property in `${NestedPathsOfType<TSchema, any[]>}.$${`[${string}]` | ""}`]?: ArrayElement<PropertyType<TSchema, Property extends `${infer Key}.$${string}` ? Key : never>> } & { [ Property in `${NestedPathsOfType<TSchema, Record<string, any>[]>}.$${`[${string}]` | ""}.${string}`]?: any }>

    Type parameters

    • TSchema

    MongoClientEvents: Pick<TopologyEvents, typeof MONGO_CLIENT_EVENTS[number]> & { open: any }
    MongoErrorLabel: typeof MongoErrorLabel[keyof typeof MongoErrorLabel]
    MonitorEvents: { close: any; resetConnectionPool: any; resetServer: any; serverHeartbeatFailed: any; serverHeartbeatStarted: any; serverHeartbeatSucceeded: any } & EventEmitterWithState
    NestedPaths<Type>: Type extends string | number | boolean | Date | RegExp | Buffer | Uint8Array | ((...args: any[]) => any) | { _bsontype: string } ? [] : Type extends ReadonlyArray<infer ArrayType> ? [] | [number, ...NestedPaths<ArrayType>] : Type extends Map<string, any> ? [string] : Type extends object ? { [ Key in Extract<keyof Type, string>]: Type[Key] extends Type ? [Key] : Type extends Type[Key] ? [Key] : Type[Key] extends ReadonlyArray<infer ArrayType> ? Type extends ArrayType ? [Key] : ArrayType extends Type ? [Key] : [Key, ...NestedPaths<Type[Key]>] : [Key, ...NestedPaths<Type[Key]>] }[Extract<keyof Type, string>] : []

    Type parameters

    • Type

    NestedPathsOfType<TSchema, Type>: KeysOfAType<{ [ Property in Join<NestedPaths<TSchema>, ".">]: PropertyType<TSchema, Property> }, Type>

    Type parameters

    • TSchema

    • Type

    NonObjectIdLikeDocument: { [ key in keyof ObjectIdLike]?: never } & Document
    NotAcceptedFields<TSchema, FieldType>: { readonly [ key in KeysOfOtherType<TSchema, FieldType>]?: never }

    It avoids using fields with not acceptable types @public

    Type parameters

    • TSchema

    • FieldType

    NumericType: IntegerType | Decimal128 | Double
    OneOrMore<T>: T | ReadonlyArray<T>

    Type parameters

    • T

    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: Timestamp

    Represents a specific point in time on a server. Can be retrieved by using db.command()

    see

    https://www.mongodb.com/docs/manual/reference/method/db.runCommand/#response

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

    Add an optional _id field to an object shaped type

    Type parameters

    • TSchema

    OptionalUnlessRequiredId<TSchema>: TSchema extends { _id: any } ? TSchema : OptionalId<TSchema>

    Adds an optional _id field to an object shaped type, unless the _id field is requried on that type. In the case _id is required, this method continues to require_id.

    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

    ProfilingLevel: typeof ProfilingLevel[keyof typeof ProfilingLevel]
    ProfilingLevelOptions: CommandOperationOptions
    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: Document
    deprecated

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

    PropertyType<Type, Property>: string extends Property ? unknown : Property extends keyof Type ? Type[Property] : Property extends `${number}` ? Type extends ReadonlyArray<infer ArrayType> ? ArrayType : unknown : Property extends `${infer Key}.${infer Rest}` ? Key extends `${number}` ? Type extends ReadonlyArray<infer ArrayType> ? PropertyType<ArrayType, Rest> : unknown : Key extends keyof Type ? Type[Key] extends Map<string, infer MapType> ? MapType : PropertyType<Type[Key], Rest> : unknown : unknown

    Type parameters

    • Type

    • Property: string

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

    Type parameters

    • TSchema

    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<TSchema>: ({ readonly [ key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: Flatten<TSchema[key]> | ArrayOperator<Flatten<TSchema[key]>[]> } & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {}

    Type parameters

    • TSchema

    ReadConcernLevel: typeof ReadConcernLevel[keyof typeof ReadConcernLevel]
    ReadConcernLike: ReadConcern | { level: ReadConcernLevel } | ReadConcernLevel
    ReadPreferenceLike: ReadPreference | ReadPreferenceMode
    ReadPreferenceMode: typeof ReadPreferenceMode[keyof typeof ReadPreferenceMode]
    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<T>: T extends string ? BSONRegExp | RegExp | T : T

    Type parameters

    • T

    RemoveUserOptions: CommandOperationOptions
    ResumeToken: unknown

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

    see

    https://www.mongodb.com/docs/manual/changeStreams/#std-label-change-stream-resume

    ReturnDocument: typeof ReturnDocument[keyof typeof ReturnDocument]
    RunCommandOptions: CommandOperationOptions
    SchemaMember<T, V>: { [ P in keyof T]?: V } | {}

    Type parameters

    • T

    • V

    ServerApiVersion: typeof ServerApiVersion[keyof typeof ServerApiVersion]
    ServerEvents: { closed: any; connect: any; descriptionReceived: any; ended: any; serverHeartbeatFailed: any; serverHeartbeatStarted: any; serverHeartbeatSucceeded: any } & ConnectionPoolEvents & EventEmitterWithState
    ServerOptions: Omit<ConnectionPoolOptions, "id" | "generation" | "hostAddress"> & MonitorOptions
    ServerSelector: (topologyDescription: TopologyDescription, servers: ServerDescription[]) => ServerDescription[]

    Type declaration

    ServerSessionId: { id: Binary }

    Type declaration

    ServerType: typeof ServerType[keyof typeof ServerType]
    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: CommandOperationOptions
    Sort: string | Exclude<SortDirection, { $meta: string }> | string[] | {} | Map<string, SortDirection> | [string, SortDirection][] | [string, SortDirection]
    SortDirection: 1 | -1 | "asc" | "desc" | "ascending" | "descending" | { $meta: string }
    Stream: Socket | TLSSocket
    SupportedSocketOptions: Pick<TcpNetConnectOpts, typeof LEGAL_TCP_SOCKET_OPTIONS[number]>
    SupportedTLSConnectionOptions: Pick<TLSConnectionOptions, Extract<keyof TLSConnectionOptions, typeof LEGAL_TLS_SOCKET_OPTIONS[number]>>
    SupportedTLSSocketOptions: Pick<TLSSocketOptions, Extract<keyof TLSSocketOptions, typeof LEGAL_TLS_SOCKET_OPTIONS[number]>>
    TagSet: {}

    Type declaration

    • [key: string]: string
    TopologyEvents: { close: any; connect: any; error: any; serverClosed: any; serverDescriptionChanged: any; serverOpening: any; timeout: any; topologyClosed: any; topologyDescriptionChanged: any; topologyOpening: any } & Omit<ServerEvents, "connect"> & ConnectionPoolEvents & ConnectionEvents & EventEmitterWithState
    TopologyType: typeof TopologyType[keyof typeof TopologyType]
    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: number | "majority"
    WithId<TSchema>: EnhancedOmit<TSchema, "_id"> & { _id: InferIdType<TSchema> }

    Add an _id field to an object shaped type @public

    Type parameters

    • TSchema

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

    Type declaration

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

    Type parameters

    • T = void

    Type declaration

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

    Remove the _id field from an object shaped type @public

    Type parameters

    • TSchema

    Variables

    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" }> = ...
    AutoEncryptionLoggerLevel: Readonly<{ Error: 1; FatalError: 0; Info: 3; Trace: 4; Warning: 2 }> = ...
    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 }> = ...
    BatchType: Readonly<{ DELETE: 3; INSERT: 1; UPDATE: 2 }> = ...
    CURSOR_FLAGS: readonly ["tailable", "oplogReplay", "noCursorTimeout", "awaitData", "exhaust", "partial"] = ...
    Compressor: Readonly<{ none: 0; snappy: 1; zlib: 2; zstd: 3 }> = ...
    ExplainVerbosity: Readonly<{ allPlansExecution: "allPlansExecution"; executionStats: "executionStats"; queryPlanner: "queryPlanner"; queryPlannerExtended: "queryPlannerExtended" }> = ...
    GSSAPICanonicalizationValue: Readonly<{ forward: "forward"; forwardAndReverse: "forwardAndReverse"; none: "none"; off: false; on: true }> = ...
    LEGAL_TCP_SOCKET_OPTIONS: readonly ["family", "hints", "localAddress", "localPort", "lookup"] = ...
    LEGAL_TLS_SOCKET_OPTIONS: readonly ["ALPNProtocols", "ca", "cert", "checkServerIdentity", "ciphers", "crl", "ecdhCurve", "key", "minDHSize", "passphrase", "pfx", "rejectUnauthorized", "secureContext", "secureProtocol", "servername", "session"] = ...
    LoggerLevel: Readonly<{ DEBUG: "debug"; ERROR: "error"; INFO: "info"; WARN: "warn"; debug: "debug"; error: "error"; info: "info"; warn: "warn" }> = ...
    MONGO_CLIENT_EVENTS: readonly ["connectionPoolCreated", "connectionPoolClosed", "connectionCreated", "connectionReady", "connectionClosed", "connectionCheckOutStarted", "connectionCheckOutFailed", "connectionCheckedOut", "connectionCheckedIn", "connectionPoolCleared", "commandStarted", "commandSucceeded", "commandFailed", "serverOpening", "serverClosed", "serverDescriptionChanged", "topologyOpening", "topologyClosed", "topologyDescriptionChanged", "error", "timeout", "close", "serverHeartbeatStarted", "serverHeartbeatSucceeded", "serverHeartbeatFailed"] = ...
    Map: MapConstructor
    MongoErrorLabel: Readonly<{ HandshakeError: "HandshakeError"; ResumableChangeStreamError: "ResumableChangeStreamError"; RetryableWriteError: "RetryableWriteError"; TransientTransactionError: "TransientTransactionError"; UnknownTransactionCommitResult: "UnknownTransactionCommitResult" }> = ...
    ObjectID: typeof ObjectId = ObjectId
    deprecated

    Please use ObjectId

    ProfilingLevel: Readonly<{ all: "all"; off: "off"; slowOnly: "slow_only" }> = ...
    ReadConcernLevel: Readonly<{ available: "available"; linearizable: "linearizable"; local: "local"; majority: "majority"; snapshot: "snapshot" }> = ...
    ReadPreferenceMode: Readonly<{ nearest: "nearest"; primary: "primary"; primaryPreferred: "primaryPreferred"; secondary: "secondary"; secondaryPreferred: "secondaryPreferred" }> = ...
    ReturnDocument: Readonly<{ AFTER: "after"; BEFORE: "before" }> = ...
    ServerApiVersion: Readonly<{ v1: "1" }> = ...
    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

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

    An enumeration of topology types we know about

    Generated using TypeDoc