当前位置: 首页>>代码示例>>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;未经允许,请勿转载。