當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。