From 8a1da913eb691c6c413b187f550f1aa58d1dfbb9 Mon Sep 17 00:00:00 2001 From: buuug7 Date: Thu, 1 Aug 2019 23:41:15 +0800 Subject: [PATCH] add support for multiple connections in `ormconfig.[format]`. --- src/connection.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/connection.ts b/src/connection.ts index d12262d3..4b6444d4 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -17,6 +17,13 @@ export const getConnectionOptions = async (configPath = 'ormconfig.js'): Promise } export const createConnection = async (configPath: string): Promise => { - const options = await getConnectionOptions(configPath) + let options = await getConnectionOptions(configPath) + if (Array.isArray(options)) { + options.forEach(item => { + if (item.name === 'default') { + options = item + } + }) + } return createTypeORMConnection(options as TypeORMConnectionOptions) }