Options
All
  • Public
  • Public/Protected
  • All
Menu

NestJS Mongo - v0.13.2

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

EventCallback<Model>: (eventName: string, change: ChangeStreamDocument<Model>) => void

Type parameters

Type declaration

    • (eventName: string, change: ChangeStreamDocument<Model>): void
    • Parameters

      • eventName: string
      • change: ChangeStreamDocument<Model>

      Returns void

ExceptionFactory: (errors: ValidationError[]) => any

Type declaration

    • (errors: ValidationError[]): any
    • Parameters

      • errors: ValidationError[]

      Returns any

IsUniqueOptions: ValidationOptions & { keys?: string[]; noIndex?: boolean; sparse?: boolean }
RelationshipTypeDescriptor<Relationship>: (obj?: any) => ClassConstructor<Relationship> | false

Type parameters

Type declaration

    • (obj?: any): ClassConstructor<Relationship> | false
    • The signature of the function used to determine the type of a relationship target

      Parameters

      • Optional obj: any

      Returns ClassConstructor<Relationship> | false

WithRelationshipTest: (object: any, relationship: any, em: EntityManager, session?: ClientSession) => Promise<string | true>

Type declaration

    • (object: any, relationship: any, em: EntityManager, session?: ClientSession): Promise<string | true>
    • Parameters

      • object: any
      • relationship: any
      • em: EntityManager
      • Optional session: ClientSession

      Returns Promise<string | true>

WithValidRelationship: (object: any, relationship: any, em: EntityManager) => Promise<string | true>

Type declaration

    • (object: any, relationship: any, em: EntityManager): Promise<string | true>
    • Parameters

      Returns Promise<string | true>

Variables

DEBUG: "nestjs-mongo" = 'nestjs-mongo'
DEFAULT_CONNECTION_NAME: "nestjs-mongo:connection:default" = 'nestjs-mongo:connection:default'
EXCLUDED_PREFIXES: string[] = ...
INDEX_METADATA_NAME: "nestjs-mongo:index" = 'nestjs-mongo:index'
MONGO_SESSION_KEY: "ns_sessionloader:mongo_client_session" = 'ns_sessionloader:mongo_client_session'
NAMED_CONNECTION_TOKEN: "nestjs-mongo:connection:name" = 'nestjs-mongo:connection:name'
RELATIONSHIP_LIST_METADATA_NAME: "nestjs-mongo:relationship_list" = 'nestjs-mongo:relationship_list'
RELATIONSHIP_METADATA_NAME: "nestjs-mongo:relationship" = 'nestjs-mongo:relationship'
SESSION_LOADER_NAMESPACE: "nestjs-mongo:ns_sessionloader" = 'nestjs-mongo:ns_sessionloader'

Functions

  • Collection(name: string): (target: any) => void
  • Parameters

    • name: string

    Returns (target: any) => void

      • (target: any): void
      • Parameters

        • target: any

        Returns void

  • Index(metadata?: Partial<IndexDescription> & CreateIndexesOptions): (target: any, property: string) => void
  • Parameters

    • Optional metadata: Partial<IndexDescription> & CreateIndexesOptions

    Returns (target: any, property: string) => void

      • (target: any, property: string): void
      • Parameters

        • target: any
        • property: string

        Returns void

  • InjectEntityManager(connectionName?: string): (target: object, key: string | symbol, index?: number) => void
  • Parameters

    • connectionName: string = DEFAULT_CONNECTION_NAME

    Returns (target: object, key: string | symbol, index?: number) => void

      • (target: object, key: string | symbol, index?: number): void
      • Decorator that marks a constructor parameter as a target for Dependency Injection (DI).

        Any injected provider must be visible within the module scope (loosely speaking, the containing module) of the class it is being injected into. This can be done by:

        • defining the provider in the same module scope
        • exporting the provider from one module scope and importing that module into the module scope of the class being injected into
        • exporting the provider from a module that is marked as global using the @Global() decorator

        Injection tokens

        Can be types (class names), strings or symbols. This depends on how the provider with which it is associated was defined. Providers defined with the @Injectable() decorator use the class name. Custom Providers may use strings or symbols as the injection token.

        see

        Providers

        see

        Custom Providers

        see

        Injection Scopes

        publicapi

        Parameters

        • target: object
        • key: string | symbol
        • Optional index: number

        Returns void

  • InjectEntityRepository(entity: ClassConstructor<any>, connectionName?: string): (target: object, key: string | symbol, index?: number) => void
  • Parameters

    • entity: ClassConstructor<any>
    • connectionName: string = DEFAULT_CONNECTION_NAME

    Returns (target: object, key: string | symbol, index?: number) => void

      • (target: object, key: string | symbol, index?: number): void
      • Decorator that marks a constructor parameter as a target for Dependency Injection (DI).

        Any injected provider must be visible within the module scope (loosely speaking, the containing module) of the class it is being injected into. This can be done by:

        • defining the provider in the same module scope
        • exporting the provider from one module scope and importing that module into the module scope of the class being injected into
        • exporting the provider from a module that is marked as global using the @Global() decorator

        Injection tokens

        Can be types (class names), strings or symbols. This depends on how the provider with which it is associated was defined. Providers defined with the @Injectable() decorator use the class name. Custom Providers may use strings or symbols as the injection token.

        see

        Providers

        see

        Custom Providers

        see

        Injection Scopes

        publicapi

        Parameters

        • target: object
        • key: string | symbol
        • Optional index: number

        Returns void

  • InjectMongoClient(connectionName?: string): (target: object, key: string | symbol, index?: number) => void
  • Parameters

    • connectionName: string = DEFAULT_CONNECTION_NAME

    Returns (target: object, key: string | symbol, index?: number) => void

      • (target: object, key: string | symbol, index?: number): void
      • Decorator that marks a constructor parameter as a target for Dependency Injection (DI).

        Any injected provider must be visible within the module scope (loosely speaking, the containing module) of the class it is being injected into. This can be done by:

        • defining the provider in the same module scope
        • exporting the provider from one module scope and importing that module into the module scope of the class being injected into
        • exporting the provider from a module that is marked as global using the @Global() decorator

        Injection tokens

        Can be types (class names), strings or symbols. This depends on how the provider with which it is associated was defined. Providers defined with the @Injectable() decorator use the class name. Custom Providers may use strings or symbols as the injection token.

        see

        Providers

        see

        Custom Providers

        see

        Injection Scopes

        publicapi

        Parameters

        • target: object
        • key: string | symbol
        • Optional index: number

        Returns void

  • IsUnique(options?: IsUniqueOptions): (target: any, propertyName: string) => void
  • Type parameters

    Parameters

    Returns <TFunction, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void

      • <TFunction, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>): void
      • Function that returns a new decorator that applies all decorators provided by param

        Useful to build new decorators (or a decorator factory) encapsulating multiple decorators related with the same feature

        publicapi

        Type parameters

        • TFunction: Function

        • Y

        Parameters

        • target: object | TFunction
        • Optional propertyKey: string | symbol
        • Optional descriptor: TypedPropertyDescriptor<Y>

        Returns void

  • Serializable(): (target: any) => void
  • Extend a class to be serializable, add 2 methods serialize() and toJSON()

    Returns (target: any) => void

      • (target: any): void
      • Parameters

        • target: any

        Returns void

  • SlugDecorator<T>(target: any, key: string, config: ISlugifyOptions<T>): void
  • Slugify<T>(config: ISlugifyOptions<T>): <TFunction, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void
  • Type parameters

    • T = any

    Parameters

    • config: ISlugifyOptions<T>

    Returns <TFunction, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void

      • <TFunction, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>): void
      • Function that returns a new decorator that applies all decorators provided by param

        Useful to build new decorators (or a decorator factory) encapsulating multiple decorators related with the same feature

        publicapi

        Type parameters

        • TFunction: Function

        • Y

        Parameters

        • target: object | TFunction
        • Optional propertyKey: string | symbol
        • Optional descriptor: TypedPropertyDescriptor<Y>

        Returns void

  • TypeObjectId(isArray?: boolean): <TFunction, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void
  • Parameters

    • Optional isArray: boolean

    Returns <TFunction, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void

      • <TFunction, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>): void
      • Function that returns a new decorator that applies all decorators provided by param

        Useful to build new decorators (or a decorator factory) encapsulating multiple decorators related with the same feature

        publicapi

        Type parameters

        • TFunction: Function

        • Y

        Parameters

        • target: object | TFunction
        • Optional propertyKey: string | symbol
        • Optional descriptor: TypedPropertyDescriptor<Y>

        Returns void

  • ensureSequentialTransaction<F>(ctx: ClientSessionContext, jobFn: F): Promise<ReturnType<F>>
  • Type parameters

    • F: () => Promise<any>

    Parameters

    • ctx: ClientSessionContext
    • jobFn: F

    Returns Promise<ReturnType<F>>

  • fromPlain<Model>(classType: ClassConstructor<Model>, data: object, options?: ClassTransformOptions): Model
  • getConfigToken(connectionName?: string): string
  • getConnectionToken(connectionName?: string): string
  • getDataloaderToken(model: string, connectionName?: string): string
  • getEntityManagerToken(connectionName?: string): string
  • getEntityRepositoryToken(model: string, connectionName?: string): string
  • getIndexMetadata(target: any, property: string): IndexMetadata | undefined
  • getObjectName(o: Object): string
  • getRelationshipCascadesMetadata<Parent, Child>(parent: ClassConstructor<Parent>, relationshipType: ClassConstructor<Child>): RelationshipCascade<Child> | undefined
  • Get relationship metadata

    Type parameters

    Parameters

    • target: Function

      A class constructor

    • property: string

      The property that was set as relationship

    • Optional em: EntityManager

      The entity manager (only required if the relationship target type is set as a string)

    • Optional obj: any

      The instance of the entity (only required if the type of the relationship is dynamic)

    Returns RelationshipMetadata<R>

  • getRelationshipsCascadesMetadata<Parent>(target: ClassConstructor<Parent>): RelationshipCascade[]
  • isClass(fn: any): boolean
  • merge<Model>(entity: Model, data: Model, excludePrefixes?: string[]): Model
  • Type parameters

    Parameters

    • entity: Model

      The model to hydrate

    • data: Model

      The data to merge into the entity

    • Optional excludePrefixes: string[]

      The prefixes to excludes (if the source contains key ith prefix)

    Returns Model

  • serialize(): Record<string, any>
  • setRelationshipsCascadesMetadata<Child>(ChildClass: ClassConstructor<Child>, manager: EntityManager): void
  • toJSON(): {}
  • toPlain<T>(data: T): Record<string, any>
  • transformObjectId(type: TransformationType, value: string | ObjectId): undefined | string | ObjectId