# ResultSet

<div class="jsdoc-content"><header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>
            <span class="ancestors"><a href="index.html">types</a>~</span>ResultSet<span class="signature">(result, encoder, pagingState<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h2>
        
            <div class="class-description"><p>Represents the result of a query.</p></div>
        
    
</header>


    
        

    
    </div>

## Constructor

<div class="jsdoc-content">
    

    
    <h4 class="name" id="ResultSet"><span class="type-signature"></span>new ResultSet<span class="signature">(result, encoder, pagingState<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    











    <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>result</code></td>
            

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


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

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

    

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

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


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

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

    

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

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

<span class="param-type">null</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/types/result-set.js#L19" target="_blank" rel="noopener">types/result-set.js, line 19</a></p></div>




















    
    

    

    

    

    

    

    

    
        </div>

## Members

<div class="jsdoc-content">

        
            
<h4 class="name" id="columns"><span class="type-signature">(readonly) </span>columns<span class="type-signature"> :Array&lt;{String, type}></span></h4>




<div class="description">
    <p>Gets the columns returned in this ResultSet.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">Array&lt;{String, type}></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/types/result-set.js#L145" target="_blank" rel="noopener">types/result-set.js, line 145</a></p></div>






        
            
<h4 class="name" id="info"><span class="type-signature">(readonly) </span>info<span class="type-signature"> :Object</span></h4>




<div class="description">
    <p>Information on the execution of a successful query:</p>
</div>



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


        </li>
    </ul>





    <h5 class="subsection-title">Properties:</h5>

    

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

        <th>Type</th>

        

        

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

    <tbody>
    

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

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


            
            </td>

            

            

            <td class="description last"><p>The consistency level that has been actually achieved by the query.</p></td>
        </tr>

    

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

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


            
            </td>

            

            

            <td class="description last"><p>The Cassandra host that coordinated this query.</p></td>
        </tr>

    

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

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


            
            </td>

            

            

            <td class="description last"><p>Gets the associative array of host that were queried before getting a valid response,
being the last host the one that replied correctly.</p></td>
        </tr>

    

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

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


            
            </td>

            

            

            <td class="description last"><p>The number of speculative executions (not including the first) executed before
getting a valid response.</p></td>
        </tr>

    

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

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


            
            </td>

            

            

            <td class="description last"><p>Identifier of the trace session.</p></td>
        </tr>

    

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

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


            
            </td>

            

            

            <td class="description last"><p>Warning messages generated by the server when executing the query.</p></td>
        </tr>

    

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

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


            
            </td>

            

            

            <td class="description last"><p>Whether the cluster had reached schema agreement after the execution of
this query.</p>
<p>TODO: Check if this is the case in rust driver:</p>
<p>After a successful schema-altering query (ex: creating a table), the driver will check if
the cluster's nodes agree on the new schema version. If not, it will keep retrying for a given
delay (see <code>protocolOptions.maxSchemaAgreementWaitSeconds</code>).</p>
<p>Note that the schema agreement check is only performed for schema-altering queries For other
query types, this method will always return <code>true</code>. If this method returns <code>false</code>,
clients can call <a href="../metadata/Metadata.html#checkSchemaAgreement">Metadata.checkSchemaAgreement()</a> later to
perform the check manually.</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/types/result-set.js#L182" target="_blank" rel="noopener">types/result-set.js, line 182</a></p></div>






        
            
<h4 class="name" id="nextPage"><span class="type-signature"></span>nextPage<span class="type-signature"> :function</span></h4>




<div class="description">
    <p>Method used to manually fetch the next page of results.
This method is only exposed when using the <a href="../Client.html#eachRow">Client#eachRow</a> method and there are more rows available in
following pages.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">function</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/types/result-set.js#L130" target="_blank" rel="noopener">types/result-set.js, line 130</a></p></div>






        
            
<h4 class="name" id="pageState"><span class="type-signature"></span>pageState<span class="type-signature"> :String|null</span></h4>




<div class="description">
    <p>A string token representing the current page state of query. It can be used in the following executions to
continue paging and retrieve the remained of the result for the query.</p>
</div>



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

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


        </li>
    </ul>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-default">Default Value:</dt>
    <dd class="tag-default"><ul class="dummy">
            <li>null</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/types/result-set.js#L112" target="_blank" rel="noopener">types/result-set.js, line 112</a></p></div>






        
            
<h4 class="name" id="rowLength"><span class="type-signature"></span>rowLength<span class="type-signature"> :Number</span></h4>




<div class="description">
    <p>Gets the row length of the result, regardless if the result has been buffered or not</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">Number</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/types/result-set.js#L100" target="_blank" rel="noopener">types/result-set.js, line 100</a></p></div>






        
            
<h4 class="name" id="rows"><span class="type-signature"></span>rows<span class="type-signature"> :Array&lt;Row>|undefined</span></h4>




<div class="description">
    <p>Gets an array rows returned by the query.
When the result set represents a response from a write query, this property will be <code>undefined</code>.
When the read query result contains more rows than the fetch size (5000), this property will only contain the
first rows up to fetch size. To obtain all the rows, you can use the built-in async iterator that will retrieve the
following pages of results.</p>
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">Array&lt;Row></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/types/result-set.js#L94" target="_blank" rel="noopener">types/result-set.js, line 94</a></p></div>






        
    

    
        </div>

## Methods

<div class="jsdoc-content">

        
            

    

    
    <h4 class="name" id="@@asyncIterator"><span class="type-signature"></span>@@asyncIterator<span class="signature">()</span><span class="type-signature"> &rarr; {AsyncIterator&lt;Row>}</span></h4>
    

    



<div class="description">
    <p>Gets the async iterator function.</p>
<p>Retrieves the async iterator representing the entire query result, the driver will fetch the following result
pages.</p>
<p>Use the async iterator when the query result might contain more rows than the <code>fetchSize</code>.</p>
<p>Note that using the async iterator will not affect the internal state of the <code>ResultSet</code> instance.
You should avoid using both <code>rows</code> property that contains the row instances of the first page of
results, and the async iterator, that will yield all the rows in the result regardless on the number of pages.</p>
<p>Multiple concurrent async iterations are not supported.</p>
</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/types/result-set.js#L278" target="_blank" rel="noopener">types/result-set.js, line 278</a></p></div>















<h5>Returns:</h5>

        


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


    </dd>
</dl>

    




    <h5>Example</h5>
    
        <p class="code-caption">Using for await...of statement</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>const query = 'SELECT user_id, post_id, content FROM timeline WHERE user_id = ?';
const result = await client.execute(query, [ id ], { prepare: true });
for await (const row of result) {
  console.log(row['email']);
}</pre></div></div>



        
            

    

    
    <h4 class="name" id="@@iterator"><span class="type-signature"></span>@@iterator<span class="signature">()</span><span class="type-signature"> &rarr; {Iterator&lt;Row>}</span></h4>
    

    



<div class="description">
    <p>Gets the iterator function.</p>
<p>Retrieves the iterator of the underlying fetched rows, without causing the driver to fetch the following
result pages. For more information on result paging,
<a href="http://docs.datastax.com/en/developer/nodejs-driver/latest/features/paging/">visit the documentation</a>.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    
    

    

    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li><a href="ResultSet.html#@@asyncIterator">module:types~ResultSet#@@asyncIterator</a></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/types/result-set.js#L249" target="_blank" rel="noopener">types/result-set.js, line 249</a></p></div>















<h5>Returns:</h5>

        


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


    </dd>
</dl>

    




    <h5>Example</h5>
    
        <p class="code-caption">Using for...of statement</p>
    
    <div class="highlight-javascript notranslate"><div class="highlight"><pre>const query = 'SELECT user_id, post_id, content FROM timeline WHERE user_id = ?';
const result = await client.execute(query, [ id ], { prepare: true });
for (const row of result) {
  console.log(row['email']);
}</pre></div></div>



        
            

    

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

    



<div class="description">
    <p>Returns the first row or null if the result rows are empty.</p>
</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/types/result-set.js#L208" target="_blank" rel="noopener">types/result-set.js, line 208</a></p></div>




















        
            

    

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

    



<div class="description">
    <p>Determines whether there are more pages of results.
If so, the driver will initially retrieve and contain only the first page of results.
To obtain all the rows, use the <a href="ResultSet.html#@@asyncIterator"><code>AsyncIterator</code></a>.</p>
</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/types/result-set.js#L328" target="_blank" rel="noopener">types/result-set.js, line 328</a></p></div>















<h5>Returns:</h5>

        


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


    </dd>
</dl>

    





        
            

    

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

    



<div class="description">
    <p>When this instance is the result of a conditional update query, it returns whether it was successful.
Otherwise, it returns <code>true</code>.</p>
<p>For consistency, this method always returns <code>true</code> for non-conditional queries (although there is
no reason to call the method in that case). This is also the case for conditional DDL statements
(CREATE KEYSPACE... IF NOT EXISTS, CREATE TABLE... IF NOT EXISTS), for which the server doesn't return
information whether it was applied or not.</p>
</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/types/result-set.js#L224" target="_blank" rel="noopener">types/result-set.js, line 224</a></p></div></div>
