当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript typeorm.getConnectionOptions函数代码示例

本文整理汇总了TypeScript中typeorm.getConnectionOptions函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getConnectionOptions函数的具体用法?TypeScript getConnectionOptions怎么用?TypeScript getConnectionOptions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getConnectionOptions函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: async

 useFactory: async () => {
   Log.log.debug(` * ${new Date().toISOString()}: Setting up TypeORM`);
   const config = await getConnectionOptions('default');
   return Object.assign(config, {
     logger: new OrmLog('all')
   })
 }
开发者ID:OysteinAmundsen,项目名称:gymsystems,代码行数:7,代码来源:common.module.ts

示例2: async

export const ormOptions = async (databaseName: string, appHomeDirPath: string, appRootPath: string) => {
    if (!databaseName) {
        throw new Error(`No database name was defined. Define DB_NAME property in your .env file.`);
    }

    const connectionOptions = await getConnectionOptions();
    // overwrite the dynamic config parts
    Object.assign(connectionOptions, {
        database: path.join(appHomeDirPath, databaseName),
        entities: [path.join(appRootPath, 'server/src/entity/**/*.{ts,js}')],
        migrations: [path.join(appRootPath, 'server/src/migration/**/*.{ts,js}')],
        subscribers: [path.join(appRootPath, 'server/src/subscriber/**/*.{ts,js}')]
    });
    return connectionOptions;
};
开发者ID:pschild,项目名称:image-management-tool,代码行数:15,代码来源:typeOrmConfig.ts

示例3: async

const initTypeORM = async () => {
    const loadedConnectionOptions = await getConnectionOptions();

    const connectionOptions = Object.assign(loadedConnectionOptions, {
        type: env.db.type as any, // See createConnection options for valid types
        host: env.db.host,
        port: env.db.port,
        username: env.db.username,
        password: env.db.password,
        database: env.db.database,
        synchronize: env.db.synchronize,
        logging: env.db.logging,
        entities: env.app.dirs.entities,
        migrations: env.app.dirs.migrations,
    });

    return createConnection(connectionOptions);
};
开发者ID:LogansUA,项目名称:jest-import-error,代码行数:18,代码来源:app.ts

示例4: async

export const connectWithRetry = async (retries = 5, timeout = 500) => {
    const connectionOptions = Object.assign(
        await getConnectionOptions(),
        {
            host: process.env.TYPEORM_HOST,
            username: process.env.TYPEORM_USERNAME,
            password: process.env.TYPEORM_PASSWORD,
            database: process.env.TYPEORM_DATABASE
        },
        process.env.NODE_ENV === "production"
            ? {
                  entities: [process.env.TYPEORM_ENTITIES_DIR],
                  subscribers: [process.env.TYPEORM_SUBSCRIBERS_DIR],
                  migrations: [process.env.TYPEORM_MIGRATIONS_DIR]
              }
            : {}
    );

    try {
        await createConnection(connectionOptions);
        logger.info("DB Connected");
    } catch (e) {
        logger.error(e);

        if (retries > 0) {
            setTimeout(() => {
                logger.warn(
                    `Retrying connection, retrys remaining: ${retries}, timeout: ${timeout}`
                );
                connectWithRetry(retries - 1, timeout);
            }, timeout);
        } else {
            logger.error(new Error(`DB connection failed with retrys`));
            return;
        }
    }
};
开发者ID:mattcroberts,项目名称:tic-tac-toe,代码行数:37,代码来源:db.ts

示例5: async

export const createTypeormConn = async () => {
    // node env changes whether we are testing or running
    const connectionOptions = await getConnectionOptions(process.env.NODE_ENV);
    return createConnection({...connectionOptions, name: "default"});
}
开发者ID:itaygolan,项目名称:GraphQL-Typescript-Server,代码行数:5,代码来源:createTypeormConn.ts


注:本文中的typeorm.getConnectionOptions函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。