()
| 8 | |
| 9 | export class selectDatabaseCommand extends BaseCommand { |
| 10 | async run() { |
| 11 | // vscode.window.showInformationMessage('Select Database!'); |
| 12 | let connectionDetails: IConnection = EditorState.connection; |
| 13 | if (!connectionDetails) return; |
| 14 | |
| 15 | const connection = await Database.createConnection(connectionDetails, 'postgres'); |
| 16 | |
| 17 | let databases: string[] = []; |
| 18 | try { |
| 19 | const res = await connection.query('SELECT datname FROM pg_database WHERE datistemplate = false;'); |
| 20 | databases = res.rows.map<string>(database => database.datname); |
| 21 | } finally { |
| 22 | await connection.end(); |
| 23 | } |
| 24 | |
| 25 | //vscode.window.showInputBox |
| 26 | const db = await vscode.window.showQuickPick(databases, {placeHolder: 'Select a database'}); |
| 27 | if (!db) return; |
| 28 | EditorState.connection = Database.getConnectionWithDB(connectionDetails, db); |
| 29 | } |
| 30 | } |
nothing calls this directly
no test coverage detected