Class: Cql::Client::QueryResult
- Inherits:
-
Object
- Object
- Cql::Client::QueryResult
- Includes:
- Enumerable
- Defined in:
- lib/cql/client/query_result.rb
Overview
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.
Instance Attribute Summary collapse
- #metadata ⇒ ResultMetadata readonly
-
#trace_id ⇒ Cql::Uuid
readonly
The ID of the query trace associated with the query, if any.
Instance Method Summary collapse
-
#each {|row| ... } ⇒ Enumerable<Hash>
(also: #each_row)
Iterates over each row in the result set.
-
#empty? ⇒ Boolean
Returns whether or not there are any rows in this result set.
-
#last_page? ⇒ Boolean
Returns true when there are no more pages to load.
-
#next_page ⇒ Object
Returns the next page or nil when there is no next page.
Instance Attribute Details
#metadata ⇒ ResultMetadata (readonly)
19 20 21 |
# File 'lib/cql/client/query_result.rb', line 19 def @metadata end |
#trace_id ⇒ Cql::Uuid (readonly)
The ID of the query trace associated with the query, if any.
24 25 26 |
# File 'lib/cql/client/query_result.rb', line 24 def trace_id @trace_id end |
Instance Method Details
#each {|row| ... } ⇒ Enumerable<Hash> Also known as: each_row
Iterates over each row in the result set.
46 47 48 |
# File 'lib/cql/client/query_result.rb', line 46 def each(&block) @rows.each(&block) end |
#empty? ⇒ Boolean
Returns whether or not there are any rows in this result set
38 39 40 |
# File 'lib/cql/client/query_result.rb', line 38 def empty? @rows.empty? end |
#last_page? ⇒ Boolean
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 Client#execute or
PreparedStatement#execute.
58 59 60 |
# File 'lib/cql/client/query_result.rb', line 58 def last_page? true end |
#next_page ⇒ Object
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 Client#execute or
PreparedStatement#execute.
69 70 71 |
# File 'lib/cql/client/query_result.rb', line 69 def next_page nil end |