MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / query

Method query

lib/control-connection.js:965–981  ·  view source on GitHub ↗

* Executes a query using the active connection * @param {String|Request} cqlQuery * @param {Boolean} [waitReconnect] Determines if it should wait for reconnection in case the control connection is not * connected at the moment. Default: true.

(cqlQuery, waitReconnect = true)

Source from the content-addressed store, hash-verified

963 * connected at the moment. Default: true.
964 */
965 async query(cqlQuery, waitReconnect = true) {
966 const queryOnConnection = async () => {
967 if (!this.connection || this._isShuttingDown) {
968 throw new errors.NoHostAvailableError({}, 'ControlConnection is not connected at the time');
969 }
970
971 const request = typeof cqlQuery === 'string' ? new requests.QueryRequest(cqlQuery, null, null) : cqlQuery;
972 return await this.connection.send(request, null);
973 };
974
975 if (!this.connection && waitReconnect) {
976 // Wait until its reconnected (or timer elapses)
977 await this._waitForReconnection();
978 }
979
980 return await queryOnConnection();
981 }
982
983 /** @returns {Encoder} The encoder used by the current connection */
984 getEncoder() {

Callers 9

_sendStartupEventMethod · 0.80
_sendStatusEventMethod · 0.80
_getTraceMethod · 0.80
_getRowsMethod · 0.80
getKeyspacesMethod · 0.80
getKeyspacesMethod · 0.80
getKeyspacesMethod · 0.80

Calls 1

_waitForReconnectionMethod · 0.95

Tested by

no test coverage detected