當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript typeorm.createConnection函數代碼示例

本文整理匯總了TypeScript中typeorm.createConnection函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createConnection函數的具體用法?TypeScript createConnection怎麽用?TypeScript createConnection使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了createConnection函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: default

export default () =>
  createConnection({
    type: "sqlite",
    database: dbPath,
    entities: [__dirname + "/../models/*.js"],
    synchronize: true,
  }).then(conn => {
    connection = conn;
  });
開發者ID:coderfox,項目名稱:Another-SS-Panel,代碼行數:9,代碼來源:db.ts

示例2: connect

export function connect(driver: DriverOptions): Promise<Connection> {
  return createConnection({
    driver: Object.assign(driver),
    entities: [
      Phone,
    ],
    autoSchemaSync: false,
  });
}
開發者ID:empirefox,項目名稱:tompeg4,代碼行數:9,代碼來源:conn.ts

示例3: main

function main() {
  createConnection(getPostgresConfig())
    .then(() => {
      console.log('database connection successful.');

      startServer();
      startToolServer();
    })
    .catch(error => console.log(error));
}
開發者ID:A-Horse,項目名稱:bblist-backend,代碼行數:10,代碼來源:main.ts

示例4: async

 useFactory: async () => await createConnection({
     type: 'mssql',
     host: 'localhost',
     port: 1433,
     username: 'sa',
     password: 'Aa123456',
     database: 'IronManNest',
     entities: [
         __dirname + '/Users/*.entity{.ts,.js}'
     ]
 })
開發者ID:fanybook,項目名稱:Nestjs30Days,代碼行數:11,代碼來源:database.provider.ts

示例5: async

 useFactory: async (configService: ConfigService) =>
   await createConnection({
     type: "postgres",
     host: configService.getString("DB_HOST"),
     port: configService.getNumber("DB_PORT"),
     username: configService.getString("DB_USER"),
     password: configService.getString("DB_PWD"),
     database: configService.getString("DB_NAME"),
     entities: [__dirname + "/../../**/*.entity{.ts,.js}"],
     synchronize: true
   }),
開發者ID:jonathan-patalano,項目名稱:blog-api,代碼行數:11,代碼來源:database.provider.ts

示例6: async

 useFactory: async () => await createConnection({
   type: 'mysql',
   host: 'localhost',
   port: 3306,
   username: 'root',
   password: 'root',
   database: 'test',
   entities: [
     __dirname + '/../**/**.entity.ts',
   ],
   autoSchemaSync: true,
 }),
開發者ID:odykyi,項目名稱:nestjs-starter,代碼行數:12,代碼來源:database.providers.ts

示例7: async

 return async () => {
     if(connection == null) {
         connection = await createConnection({
             type: 'sqlite',
             database: 'my.db',
             entities: [
                 Todo
             ],
             synchronize: true
         });
     }
     return connection;
 }
開發者ID:loki2302,項目名稱:html5-experiment,代碼行數:13,代碼來源:index.ts

示例8: async

const newConnection = async () => {
  const con = await createConnection({
    host: 'localhost',
    type: 'mysql',
    username: 'root',
    password: 'root',
    database: 'typeorm_test',
    entities,
    synchronize: true,
    logging: ['error', 'query'],
  })

  return con
}
開發者ID:uldissturms,項目名稱:playgrounds,代碼行數:14,代碼來源:save.ts

示例9: createConnection

(async () => {
    try{
        let connection = await createConnection(dbOptions);

        console.log("connection.isConnected = " + connection.isConnected);

        await connection.getRepository(FooEntity).find(); // this will throw ECONNREFUSED

        console.log("Mysql connection ok");
    }
    catch(e){
        console.error("Mysql connection error : " + e );
    }
})();
開發者ID:joffray589,項目名稱:typeorm-sample,代碼行數:14,代碼來源:main.ts

示例10: createConnections

    private createConnections() {
        let promises: Promise<any>[] = [];

        if (this.configuration.connection)
            promises.push(createConnection(this.normalizeConnectionOptions(this.configuration.connection)));

        if (this.configuration.connections)
                this.configuration
                    .connections
                    .map(connectionOptions => createConnection(this.normalizeConnectionOptions(connectionOptions)))
                    .forEach(closePromise => promises.push(closePromise));

        return Promise.all(promises);
    }
開發者ID:pleerock,項目名稱:microframework-typeorm,代碼行數:14,代碼來源:TypeOrmModule.ts


注:本文中的typeorm.createConnection函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。