# Client

<div class="jsdoc-content"><header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>Client<span class="signature">(options)</span><span class="type-signature"></span></h2>
        
            <div class="class-description"><p>Represents a database client that maintains multiple connections to the cluster nodes, providing methods to
execute CQL statements.</p>
<p>The <code>Client</code> uses <a href="policies/index.html">policies</a> to decide which nodes to connect to, which node
to use per each query execution, when it should retry failed or timed-out executions and how reconnection to down
nodes should be made.</p></div>
        
    
</header>


    
        

    
    </div>

## Constructor

<div class="jsdoc-content">
    

    
    <h4 class="name" id="Client"><span class="type-signature"></span>new Client<span class="signature">(options)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Creates a new instance of <a href="Client.html">Client</a>.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">clientOptions.ClientOptions</span>


            
            </td>

            

            

            <td class="description last"><p>The options for this instance.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L74" target="_blank" rel="noopener">client.js, line 74</a></p></div>



















    <h5>Examples</h5>
    
        <p class="code-caption">Creating a new client instance</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>const client = new Client({
  contactPoints: ['10.0.1.101', '10.0.1.102'],
});</pre></div></div>

        <p class="code-caption">Executing a query</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>const result = await client.connect();
console.log(\`Connected to ${client.hosts.length} nodes in the cluster: ${client.hosts.keys().join(', ')}\`);</pre></div></div>

        <p class="code-caption">Executing a query</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>const result = await client.execute('SELECT key FROM system.local');
const row = result.first();
console.log(row['key']);</pre></div></div>



    
    

    
        </div>

## Extends

<div class="jsdoc-content">

        


    <ul>
        <li>events.EventEmitter</li>
    </ul>


    

    

    

    

    

    

    
        </div>

## Members

<div class="jsdoc-content">

        
            
<h4 class="name" id="hosts"><span class="type-signature"></span>hosts<span class="type-signature"> :<a href="HostMap.html">HostMap</a></span></h4>




<div class="description">
    <p>Gets an associative array of cluster hosts.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type"><a href="HostMap.html">HostMap</a></span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L160" target="_blank" rel="noopener">client.js, line 160</a></p></div>






        
            
<h4 class="name" id="keyspace"><span class="type-signature"></span>keyspace<span class="type-signature"> :string|undefined</span></h4>




<div class="description">
    <p>Gets the name of the active keyspace.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">string</span>
|

<span class="param-type">undefined</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L148" target="_blank" rel="noopener">client.js, line 148</a></p></div>






        
            
<h4 class="name" id="metadata"><span class="type-signature"></span>metadata<span class="type-signature"> :Metadata|undefined</span></h4>




<div class="description">
    <p>Gets the schema and cluster metadata information.
TODO: This field is currently not supported</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">Metadata</span>
|

<span class="param-type">undefined</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L108" target="_blank" rel="noopener">client.js, line 108</a></p></div>






        
            
<h4 class="name" id="metrics"><span class="type-signature"></span>metrics<span class="type-signature"> :ClientMetrics</span></h4>




<div class="description">
    <p>The <a href="metrics/ClientMetrics.html">ClientMetrics</a> instance used to expose measurements of its internal
behavior and of the server as seen from the driver side.</p>
<p>By default, a <a href="metrics/DefaultMetrics.html">DefaultMetrics</a> instance is used.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">ClientMetrics</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L117" target="_blank" rel="noopener">client.js, line 117</a></p></div>






        
            
<h4 class="name" id="options"><span class="type-signature"></span>options<span class="type-signature"> :clientOptions.ClientOptions</span></h4>






    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">clientOptions.ClientOptions</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L89" target="_blank" rel="noopener">client.js, line 89</a></p></div>






        
            
<h4 class="name" id="rustClient"><span class="type-signature">(package) </span>rustClient<span class="type-signature"> :rust.SessionWrapper</span></h4>






    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">rust.SessionWrapper</span>


        </li>
    </ul>





<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L79" target="_blank" rel="noopener">client.js, line 79</a></p></div>






        
    

    
        </div>

## Methods

<div class="jsdoc-content">

        
            

    

    
    <h4 class="name" id="batch"><span class="type-signature"></span>batch<span class="signature">(queries, options<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Executes batch of queries on an available connection to a host.</p>
<p>It returns a <code>Promise</code> when a <code>callback</code> is not provided.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>queries</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array&lt;(string|{query: string, params: ?(Array&lt;any>|Object)})></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>The queries to execute as an Array of strings or as an array
of object containing the query and params.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="globals.html#QueryOptions">QueryOptions</a></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>The query options.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="globals.html#ResultCallback">ResultCallback</a></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>Executes callback(err, result) when the batch was executed</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L766" target="_blank" rel="noopener">client.js, line 766</a></p></div>




















        
            

    

    
    <h4 class="name" id="connect"><span class="type-signature"></span>connect<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Attempts to connect to one of the <a href="globals.html#ClientOptions">contactPoints</a> and discovers the rest the nodes of the
cluster.</p>
<p>When the <a href="Client.html">Client</a> is already connected, it resolves immediately.</p>
<p>It returns a <code>Promise</code> when a <code>callback</code> is not provided.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>The optional callback that is invoked when the pool is connected or it failed to
connect.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L214" target="_blank" rel="noopener">client.js, line 214</a></p></div>



















    <h5>Example</h5>
    
        <p class="code-caption">Usage example</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>await client.connect();</pre></div></div>



        
            

    

    
    <h4 class="name" id="createOptions"><span class="type-signature">(package) </span>createOptions<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="ExecutionOptions.html">ExecutionOptions</a>}</span></h4>
    

    



<div class="description">
    <p>Manually create final execution options, applying client and default setting.</p>
<p>Creating those options requires a native call, but they can be reused
without any additional native calls, which improves performance
for queries with the same QueryOptions.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="globals.html#QueryOptions">QueryOptions</a></span>
|

<span class="param-type"><a href="ExecutionOptions.html">ExecutionOptions</a></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L180" target="_blank" rel="noopener">client.js, line 180</a></p></div>















<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="ExecutionOptions.html">ExecutionOptions</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="eachRow"><span class="type-signature"></span>eachRow<span class="signature">(query, params<span class="signature-attributes">opt</span>, options<span class="signature-attributes">opt</span>, rowCallback, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Executes the query and calls <code>rowCallback</code> for each row as soon as they are received. Calls the final
<code>callback</code> after all rows have been sent, or when there is an error.</p>
<p>The query can be prepared (recommended) or not depending on the <a href="globals.html#QueryOptions"><code>prepare</code></a> flag.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>query</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>The query to execute</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>params</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array&lt;any></span>
|

<span class="param-type">Object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>Array of parameter values or an associative array (object) containing parameter names
as keys and its value.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="globals.html#QueryOptions">QueryOptions</a></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>The query options.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>rowCallback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>Executes <code>rowCallback(n, row)</code> per each row received, where n is the row
index and row is the current Row.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>Executes <code>callback(err, result)</code> after all rows have been received.</p>
<p>When dealing with paged results, <a href="types/ResultSet.html#nextPage">ResultSet#nextPage()</a> method can be used
to retrieve the following page. In that case, <code>rowCallback()</code> will be again called for each row and
the final callback will be invoked when all rows in the following page has been retrieved.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L595" target="_blank" rel="noopener">client.js, line 595</a></p></div>



















    <h5>Examples</h5>
    
        <p class="code-caption">Using per-row callback and arrow functions</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>client.eachRow(query, params, { prepare: true }, (n, row) => console.log(n, row), err => console.error(err));</pre></div></div>

        <p class="code-caption">Overloads</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>client.eachRow(query, rowCallback);
client.eachRow(query, params, rowCallback);
client.eachRow(query, params, options, rowCallback);
client.eachRow(query, params, rowCallback, callback);
client.eachRow(query, params, options, rowCallback, callback);</pre></div></div>



        
            

    

    
    <h4 class="name" id="execute"><span class="type-signature"></span>execute<span class="signature">(query, params<span class="signature-attributes">opt</span>, options<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Executes a query on an available connection.</p>
<p>The query can be prepared (recommended) or not depending on the <a href="globals.html#QueryOptions"><code>prepare</code></a> flag.</p>
<p>Some execution failures can be handled transparently by the driver, according to the
<a href="policies/retry/RetryPolicy.html"><code>RetryPolicy</code></a> or the
<a href="policies/speculativeExecution/index.html"><code>SpeculativeExecutionPolicy</code></a> used.</p>
<p>It returns a <code>Promise</code> when a <code>callback</code> is not provided.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>query</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>The query to execute.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>params</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array&lt;any></span>
|

<span class="param-type">Object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>Array of parameter values or an associative array (object) containing parameter names
as keys and its value.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="globals.html#QueryOptions">QueryOptions</a></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>The query options for the execution.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="globals.html#ResultCallback">ResultCallback</a></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>Executes callback(err, result) when execution completed. When not defined, the
method will return a promise.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    
    

    

    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li><a href="ExecutionProfile.html">ExecutionProfile</a> to reuse a set of options across different query executions.</li>
        </ul>
    </dd>
    

    
</dl><div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L332" target="_blank" rel="noopener">client.js, line 332</a></p></div>



















    <h5>Examples</h5>
    
        <p class="code-caption">Promise-based API, using async/await</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>const query = 'SELECT name, email FROM users WHERE id = ?';
const result = await client.execute(query, [ id ], { prepare: true });
const row = result.first();
console.log('%s: %s', row['name'], row['email']);</pre></div></div>

        <p class="code-caption">Callback-based API</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>const query = 'SELECT name, email FROM users WHERE id = ?';
client.execute(query, [ id ], { prepare: true }, function (err, result) {
  assert.ifError(err);
  const row = result.first();
  console.log('%s: %s', row['name'], row['email']);
});</pre></div></div>



        
            

    

    
    <h4 class="name" id="executeGraph"><span class="type-signature"></span>executeGraph<span class="signature">()</span><span class="type-signature"></span></h4>
    

    















<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L564" target="_blank" rel="noopener">client.js, line 564</a></p></div>
<div class="admonition warning"><p class="admonition-title">Deprecated</p><p>Not supported by the driver. Usage will throw an error.</p></div>




















        
            

    

    
    <h4 class="name" id="getReplicas"><span class="type-signature"></span>getReplicas<span class="signature">(keyspace, token)</span><span class="type-signature"> &rarr; {Array&lt;<a href="Host.html">Host</a>>}</span></h4>
    

    



<div class="description">
    <p>Gets the host that are replicas of a given token.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>keyspace</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>token</code></td>
            

            <td class="type">
            
                
<span class="param-type">Buffer</span>


            
            </td>

            

            

            <td class="description last"></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L871" target="_blank" rel="noopener">client.js, line 871</a></p></div>















<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Array&lt;<a href="Host.html">Host</a>></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getState"><span class="type-signature"></span>getState<span class="signature">()</span><span class="type-signature"> &rarr; {ClientState}</span></h4>
    

    















<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L882" target="_blank" rel="noopener">client.js, line 882</a></p></div>
<div class="admonition warning"><p class="admonition-title">Deprecated</p><p>This is not planned feature for the driver. Currently this remains in place, but returns Client state with
no information. This endpoint may be removed at any point.</p></div>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A dummy <a href="metadata/ClientState.html"><code>ClientState</code></a> instance.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">ClientState</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="prepareStatement"><span class="type-signature">(async) </span>prepareStatement<span class="signature">(statement)</span><span class="type-signature"> &rarr; {Promise&lt;PreparedInfo>}</span></h4>
    

    



<div class="description">
    <p>Manually prepare query into prepared statement.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>statement</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L195" target="_blank" rel="noopener">client.js, line 195</a></p></div>















<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise&lt;PreparedInfo></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="rustyExecute"><span class="type-signature">(async, package) </span>rustyExecute<span class="signature">(query, params, execOptions, pageState<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise&lt;ResultSet>}</span></h4>
    

    



<div class="description">
    <p>Wrapper for executing queries by rust driver.
When called with a pageState argument (including null), executes a single-page query.
When called without pageState, executes an unpaged query.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>query</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">PreparedInfo</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>params</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array&lt;any></span>
|

<span class="param-type">Object</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>execOptions</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="ExecutionOptions.html">ExecutionOptions</a></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>pageState</code></td>
            

            <td class="type">
            
                
<span class="param-type">rust.PagingStateWrapper</span>
|

<span class="param-type">Buffer</span>
|

<span class="param-type">null</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>When provided (including null), enables paged execution.
When unprovided (undefined), executes an unpaged query.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L384" target="_blank" rel="noopener">client.js, line 384</a></p></div>















<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise&lt;ResultSet></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="shutdown"><span class="type-signature"></span>shutdown<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>The only effect of calling shutdown is rejecting any following queries to the database.</p>
<p>It returns a <code>Promise</code> when a <code>callback</code> is not provided.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>Optional callback to be invoked when finished closing all connections.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L898" target="_blank" rel="noopener">client.js, line 898</a></p></div>
<div class="admonition warning"><p class="admonition-title">Deprecated</p><p>Explicit connection shutdown is deprecated and may be removed in the future.
Drop this client to close the connection to the database.</p></div>




















        
            

    

    
    <h4 class="name" id="stream"><span class="type-signature"></span>stream<span class="signature">(query, params<span class="signature-attributes">opt</span>, options<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {ResultStream}</span></h4>
    

    



<div class="description">
    <p>Executes the query and pushes the rows to the result stream as soon as they received.</p>
<p>The stream is a <a href="https://nodejs.org/api/stream.html#stream_class_stream_readable">ReadableStream</a> object
that emits rows.
It can be piped downstream and provides automatic pause/resume logic (it buffers when not read).</p>
<p>The query can be prepared (recommended) or not depending on <a href="globals.html#QueryOptions">QueryOptions</a>.prepare flag. Retries on multiple
hosts if needed.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>query</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>The query to prepare and execute.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>params</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array&lt;any></span>
|

<span class="param-type">Object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>Array of parameter values or an associative array (object) containing parameter names
as keys and its value</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="globals.html#QueryOptions">QueryOptions</a></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>The query options.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>executes callback(err) after all rows have been received or if there is an error</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L700" target="_blank" rel="noopener">client.js, line 700</a></p></div>















<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">ResultStream</span>


    </dd>
</dl>

    





        
    

    

    
        </div>

## Events

<div class="jsdoc-content">

        
            

    

    
    <h4 class="name" id="event:hostAdd">hostAdd</h4>
    

    



<div class="description">
    <p>Emitted when a new host is added to the cluster.</p>
<ul>
<li><a href="Host.html">Host</a> The host being added.</li>
</ul>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L123" target="_blank" rel="noopener">client.js, line 123</a></p></div>




















        
            

    

    
    <h4 class="name" id="event:hostDown">hostDown</h4>
    

    



<div class="description">
    <p>Emitted when a host in the cluster changed status from up to down.</p>
<ul>
<li><a href="Host.html">host</a> The host that changed the status.</li>
</ul>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L138" target="_blank" rel="noopener">client.js, line 138</a></p></div>




















        
            

    

    
    <h4 class="name" id="event:hostRemove">hostRemove</h4>
    

    



<div class="description">
    <p>Emitted when a host is removed from the cluster</p>
<ul>
<li><a href="Host.html">Host</a> The host being removed.</li>
</ul>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L128" target="_blank" rel="noopener">client.js, line 128</a></p></div>




















        
            

    

    
    <h4 class="name" id="event:hostUp">hostUp</h4>
    

    



<div class="description">
    <p>Emitted when a host in the cluster changed status from down to up.</p>
<ul>
<li><a href="Host.html">host</a> The host that changed the status.</li>
</ul>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/client.js#L133" target="_blank" rel="noopener">client.js, line 133</a></p></div></div>
