class Cql::Client::QueryResult

Query results encapsulate the rows returned by a query.

In addition to containing the rows it contains metadata about the data types of the columns of the rows, and it knows the ID of the trace, if tracing was requested for the query.

When paging over a big result you can use {#last_page?} to find out if the page is the last, or {#next_page} to retrieve the next page.

‘QueryResult` is an `Enumerable` so it can be mapped, filtered, reduced, etc.

Attributes

metadata[R]

@return [ResultMetadata]

paging_state[R]

@private

trace_id[R]

The ID of the query trace associated with the query, if any.

@return [Cql::Uuid]

Public Class Methods

new(metadata, rows, trace_id, paging_state) click to toggle source

@private

# File lib/cql/client/query_result.rb, line 30
def initialize(metadata, rows, trace_id, paging_state)
  @metadata = ResultMetadata.new(metadata)
  @rows = rows
  @trace_id = trace_id
  @paging_state = paging_state
end

Public Instance Methods

each(&block) click to toggle source

Iterates over each row in the result set.

@yieldparam [Hash] row each row in the result set as a hash @return [Enumerable<Hash>]

# File lib/cql/client/query_result.rb, line 46
def each(&block)
  @rows.each(&block)
end
Also aliased as: each_row
each_row(&block)
Alias for: each
empty?() click to toggle source

Returns whether or not there are any rows in this result set

# File lib/cql/client/query_result.rb, line 38
def empty?
  @rows.empty?
end
last_page?() click to toggle source

Returns true when there are no more pages to load.

This is only relevant when you have requested paging of the results with the ‘:page_size` option to {Cql::Client::Client#execute} or {Cql::Client::PreparedStatement#execute}.

@see Cql::Client::Client#execute

# File lib/cql/client/query_result.rb, line 58
def last_page?
  true
end
next_page() click to toggle source

Returns the next page or nil when there is no next page.

This is only relevant when you have requested paging of the results with the ‘:page_size` option to {Cql::Client::Client#execute} or {Cql::Client::PreparedStatement#execute}.

@see Cql::Client::Client#execute

# File lib/cql/client/query_result.rb, line 69
def next_page
  nil
end