* Executes multiple queries concurrently at the defined concurrency level. * @static * @param {Client} client The Client instance. * @param {String|Array<{query, params}>} query The query to execute per each parameter item. * @param {Array |Stream|Object} parameters An {@link Array
(client, query, parameters, options)
| 67 | * const result = await executeConcurrent(client, queryAndParameters); |
| 68 | */ |
| 69 | function executeConcurrent(client, query, parameters, options) { |
| 70 | if (!client) { |
| 71 | throw new TypeError('Client instance is not defined'); |
| 72 | } |
| 73 | |
| 74 | if (typeof query === 'string') { |
| 75 | if (Array.isArray(parameters)) { |
| 76 | return new ArrayBasedExecutor(client, query, parameters, options).execute(); |
| 77 | } |
| 78 | |
| 79 | if (parameters instanceof Stream) { |
| 80 | return new StreamBasedExecutor(client, query, parameters, options).execute(); |
| 81 | } |
| 82 | |
| 83 | throw new TypeError('parameters should be an Array or a Stream instance'); |
| 84 | } |
| 85 | |
| 86 | if (Array.isArray(query)) { |
| 87 | options = parameters; |
| 88 | return new ArrayBasedExecutor(client, null, query, options).execute(); |
| 89 | } |
| 90 | |
| 91 | throw new TypeError('A string query or query and parameters array should be provided'); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Wraps the functionality to execute given an Array. |
no test coverage detected