Class: Gcloud::Datastore::Dataset::QueryResults
- Inherits:
-
Array
- Object
- Array
- Gcloud::Datastore::Dataset::QueryResults
- Defined in:
- lib/gcloud/datastore/dataset/query_results.rb
Overview
QueryResults is a special case Array with additional values. A QueryResults object is returned from Dataset#run and contains the Entities from the query as well as the query’s cursor and more_results value.
entities = dataset.run query
entities.size #=> 3
entities.cursor #=> "c3VwZXJhd2Vzb21lIQ"
Please be cautious when treating the QueryResults as an Array. Many common Array methods will return a new Array instance.
entities = dataset.run query
entities.size #=> 3
entities.end_cursor #=> "c3VwZXJhd2Vzb21lIQ"
names = entities.map { |e| e.name }
names.size #=> 3
names.cursor #=> NoMethodError
Instance Attribute Summary collapse
-
#end_cursor ⇒ Object
(also: #cursor)
readonly
The end_cursor of the QueryResults.
-
#more_results ⇒ Object
readonly
The state of the query after the current batch.
Instance Method Summary collapse
-
#initialize(arr = [], end_cursor = nil, more_results = nil) ⇒ QueryResults
constructor
Create a new QueryResults with an array of values.
-
#more_after_limit? ⇒ Boolean
Convenience method for determining id the more_results value is “MORE_RESULTS_AFTER_LIMIT”.
-
#no_more? ⇒ Boolean
Convenience method for determining id the more_results value is “NO_MORE_RESULTS”.
-
#not_finished? ⇒ Boolean
Convenience method for determining id the more_results value is “NOT_FINISHED”.
Constructor Details
#initialize(arr = [], end_cursor = nil, more_results = nil) ⇒ QueryResults
Create a new QueryResults with an array of values.
81 82 83 84 85 |
# File 'lib/gcloud/datastore/dataset/query_results.rb', line 81 def initialize arr = [], end_cursor = nil, more_results = nil super arr @end_cursor = end_cursor @more_results = more_results end |
Instance Attribute Details
#end_cursor ⇒ Object (readonly) Also known as: cursor
The end_cursor of the QueryResults.
42 43 44 |
# File 'lib/gcloud/datastore/dataset/query_results.rb', line 42 def end_cursor @end_cursor end |
#more_results ⇒ Object (readonly)
The state of the query after the current batch.
Expected values are:
“MORE_RESULTS_AFTER_LIMIT”: “NOT_FINISHED”: “NO_MORE_RESULTS”:
53 54 55 |
# File 'lib/gcloud/datastore/dataset/query_results.rb', line 53 def more_results @more_results end |
Instance Method Details
#more_after_limit? ⇒ Boolean
Convenience method for determining id the more_results value is “MORE_RESULTS_AFTER_LIMIT”
66 67 68 69 |
# File 'lib/gcloud/datastore/dataset/query_results.rb', line 66 def more_after_limit? more_results == Proto.to_more_results_string( Proto::QueryResultBatch::MoreResultsType::MORE_RESULTS_AFTER_LIMIT) end |
#no_more? ⇒ Boolean
Convenience method for determining id the more_results value is “NO_MORE_RESULTS”
74 75 76 77 |
# File 'lib/gcloud/datastore/dataset/query_results.rb', line 74 def no_more? more_results == Proto.to_more_results_string( Proto::QueryResultBatch::MoreResultsType::NO_MORE_RESULTS) end |
#not_finished? ⇒ Boolean
Convenience method for determining id the more_results value is “NOT_FINISHED”
58 59 60 61 |
# File 'lib/gcloud/datastore/dataset/query_results.rb', line 58 def not_finished? more_results == Proto.to_more_results_string( Proto::QueryResultBatch::MoreResultsType::NOT_FINISHED) end |