@nestjs/typeorm

  • Version 11.0.1
  • Published
  • 39.4 kB
  • No dependencies
  • MIT license

Install

npm i @nestjs/typeorm
yarn add @nestjs/typeorm
pnpm add @nestjs/typeorm

Overview

Nest - modern, fast, powerful node.js web framework (@typeorm)

Index

Variables

variable getConnectionToken

const getConnectionToken: (dataSource?: any) => any;
  • Deprecated

Functions

function generateString

generateString: () => string;

    function getCustomRepositoryToken

    getCustomRepositoryToken: (repository: Function) => string;
    • This function generates an injection token for an Entity or Repository

      Parameter This

      parameter can either be an Entity or Repository

      Returns

      {string} The Repository injection token

    function getDataSourceName

    getDataSourceName: (options: { name?: string }) => string;

      function getDataSourcePrefix

      getDataSourcePrefix: (
      dataSource?: DataSource | DataSourceOptions | string
      ) => string;
      • This function returns a DataSource prefix based on the dataSource name

        Parameter dataSource

        This optional parameter is either a DataSource, or a DataSourceOptions or a string.

        Returns

        {string | Function} The DataSource injection token.

      function getDataSourceToken

      getDataSourceToken: (
      dataSource?: DataSource | DataSourceOptions | string
      ) => string | Function | Type<DataSource>;
      • This function returns a DataSource injection token for the given DataSource, DataSourceOptions or dataSource name.

        Parameter dataSource

        This optional parameter is either a DataSource, or a DataSourceOptions or a string.

        Returns

        {string | Function} The DataSource injection token.

      function getEntityManagerToken

      getEntityManagerToken: (
      dataSource?: DataSource | DataSourceOptions | string
      ) => string | Function;
      • This function returns an EntityManager injection token for the given DataSource, DataSourceOptions or dataSource name.

        Parameter dataSource

        This optional parameter is either a DataSource, or a DataSourceOptions or a string.

        Returns

        {string | Function} The EntityManager injection token.

      function getRepositoryToken

      getRepositoryToken: (
      entity: EntityClassOrSchema,
      dataSource?: DataSource | DataSourceOptions | string
      ) => Function | string;
      • This function generates an injection token for an Entity or Repository

        Parameter entity

        parameter can either be an Entity or Repository

        Parameter dataSource

        DataSource name

        Returns

        {string} The Entity | Repository injection token

      function handleRetry

      handleRetry: (
      retryAttempts?: number,
      retryDelay?: number,
      dataSourceName?: string,
      verboseRetryLog?: boolean,
      toRetry?: (err: any) => boolean
      ) => <T>(source: Observable<T>) => Observable<T>;

        function InjectConnection

        InjectConnection: (
        dataSource?: DataSource | DataSourceOptions | string
        ) => ReturnType<typeof Inject>;
        • Deprecated

        function InjectDataSource

        InjectDataSource: (
        dataSource?: DataSource | DataSourceOptions | string
        ) => ReturnType<typeof Inject>;

        function InjectEntityManager

        InjectEntityManager: (
        dataSource?: DataSource | DataSourceOptions | string
        ) => ReturnType<typeof Inject>;

        function InjectRepository

        InjectRepository: (
        entity: EntityClassOrSchema,
        dataSource?: string
        ) => ReturnType<typeof Inject>;

        Classes

        class TypeOrmModule

        class TypeOrmModule {}

        method forFeature

        static forFeature: (
        entities?: EntityClassOrSchema[],
        dataSource?: DataSource | DataSourceOptions | string
        ) => DynamicModule;

          method forRoot

          static forRoot: (options?: TypeOrmModuleOptions) => DynamicModule;

            method forRootAsync

            static forRootAsync: (options: TypeOrmModuleAsyncOptions) => DynamicModule;

              Interfaces

              interface TypeOrmModuleAsyncOptions

              interface TypeOrmModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {}

              property dataSourceFactory

              dataSourceFactory?: TypeOrmDataSourceFactory;

                property extraProviders

                extraProviders?: Provider[];

                  property inject

                  inject?: any[];

                    property name

                    name?: string;

                      property useClass

                      useClass?: Type<TypeOrmOptionsFactory>;

                        property useExisting

                        useExisting?: Type<TypeOrmOptionsFactory>;

                          property useFactory

                          useFactory?: (
                          ...args: any[]
                          ) => Promise<TypeOrmModuleOptions> | TypeOrmModuleOptions;

                            interface TypeOrmOptionsFactory

                            interface TypeOrmOptionsFactory {}

                            method createTypeOrmOptions

                            createTypeOrmOptions: (
                            connectionName?: string
                            ) => Promise<TypeOrmModuleOptions> | TypeOrmModuleOptions;

                              Type Aliases

                              type TypeOrmDataSourceFactory

                              type TypeOrmDataSourceFactory = (options?: DataSourceOptions) => Promise<DataSource>;

                              type TypeOrmModuleOptions

                              type TypeOrmModuleOptions = {
                              /**
                              * NestJS-level datasource identifier.
                              * In TypeORM 0.3.x this also existed on DataSourceOptions; in 1.0 it was removed.
                              */
                              name?: string;
                              /**
                              * Number of times to retry connecting
                              * Default: 10
                              */
                              retryAttempts?: number;
                              /**
                              * Delay between connection retry attempts (ms)
                              * Default: 3000
                              */
                              retryDelay?: number;
                              /**
                              * Function that determines whether the module should
                              * attempt to connect upon failure.
                              *
                              * @param err error that was thrown
                              * @returns whether to retry connection or not
                              */
                              toRetry?: (err: any) => boolean;
                              /**
                              * If `true`, entities will be loaded automatically.
                              */
                              autoLoadEntities?: boolean;
                              /**
                              * If `true`, will show verbose error messages on each connection retry.
                              */
                              verboseRetryLog?: boolean;
                              /**
                              * If `true` database initialization will not be performed during module initialization.
                              * This means that database connection will not be established and migrations will not run.
                              * Database initialization will have to be performed manually using `DataSource.initialize`
                              * and it will have to implement own retry mechanism (if necessary).
                              */
                              manualInitialization?: boolean;
                              } & Partial<DataSourceOptions>;

                              Package Files (5)

                              Dependencies (0)

                              No dependencies.

                              Dev Dependencies (29)

                              Peer Dependencies (5)

                              Badge

                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@nestjs/typeorm.

                              • Markdown
                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@nestjs/typeorm)
                              • HTML
                                <a href="https://www.jsdocs.io/package/@nestjs/typeorm"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>