Represents the result of a query.

Members

Array<{name, type}>

columns

Gets the columns returned in this ResultSet.

Object

info

Information on the execution of a successful query:

Properties:
Name Type Description
achievedConsistency Number

The consistency level that has been actually achieved by the query.

queriedHost String

The Cassandra host that coordinated this query.

triedHosts Object

Gets the associative array of host that were queried before getting a valid response, being the last host the one that replied correctly.

speculativeExecutions Object

The number of speculative executions (not including the first) executed before getting a valid response.

traceId Uuid

Identifier of the trace session.

warnings Array<string>

Warning messages generated by the server when executing the query.

isSchemaInAgreement Boolean

Whether the cluster had reached schema agreement after the execution of this query.

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 protocolOptions.maxSchemaAgreementWaitSeconds).

Note that the schema agreement check is only performed for schema-altering queries For other query types, this method will always return true. If this method returns false, clients can call Metadata.checkSchemaAgreement() later to perform the check manually.

function

nextPage

Method used to manually fetch the next page of results. This method is only exposed when using the eachRow method and there are more rows available in following pages.

String

pageState

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.

Number

rowLength

Gets the row length of the result, regardless if the result has been buffered or not

Array<Row>

rows

Gets an array rows returned by the query, in case the result was buffered.

Constructor

new

ResultSet

(Object response, String host, Object triedHosts, Number speculativeExecutions, Number consistency, Boolean isSchemaInAgreement)

Creates a new instance of ResultSet.

Parameters:
Name Type Description
response Object
host String
triedHosts Object
speculativeExecutions Number
consistency Number
isSchemaInAgreement Boolean

Methods

@@iterator

()

Gets the iterator function.

Retrieves the iterator of the underlying fetched rows and will not cause the driver to fetch the following result pages. For more information on result paging, visit the documentation.

Examples:
Using for…of statement
const query = 'SELECT name, email, address FROM users WHERE id = ?';
const result = await client.execute(query, [ id ], { prepare: true });
for (let row of result) {
  console.log(row['email']);
}
Returns:
Type Description
Iterator<Row>

first

()

Returns the first row or null if the result rows are empty.

wasApplied

()

When this instance is the result of a conditional update query, it returns whether it was successful. Otherwise, it returns true.

For consistency, this method always returns true 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.