* Gets the query id and metadata for a prepared statement, preparing it on * single host or on all hosts depending on the options. * @param {Client} client * @param {LoadBalancingPolicy} loadBalancing * @param {String} query * @param {String} keyspace * @returns {Promise<{queryId,
(client, loadBalancing, query, keyspace)
| 50 | * @static |
| 51 | */ |
| 52 | static async getPrepared(client, loadBalancing, query, keyspace) { |
| 53 | const info = client.metadata.getPreparedInfo(keyspace, query); |
| 54 | if (info.queryId) { |
| 55 | return info; |
| 56 | } |
| 57 | |
| 58 | if (info.preparing) { |
| 59 | // It's already being prepared |
| 60 | return await promiseUtils.fromEvent(info, 'prepared'); |
| 61 | } |
| 62 | |
| 63 | const instance = new PrepareHandler(client, loadBalancing); |
| 64 | return await instance._prepare(info, query, keyspace); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * @param {Client} client |
no test coverage detected