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
@return [ResultMetadata]
@private
The ID of the query trace associated with the query, if any.
@return [Cql::Uuid]
Public Class Methods
@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
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
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
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
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