Reference documentation and code samples for the Firestore in Datastore mode API class Google::Cloud::Datastore::Dataset::AggregateQueryResults.
AggregateQueryResults
An AggregateQueryResult object is a representation for a result of an AggregateQuery or a GqlQuery.
Inherits
- Object
Example
require "google/cloud/datastore" datastore = Google::Cloud::Datastore.new query = Google::Cloud::Datastore::Query.new query.kind("Task") .where("done", "=", false) Create an aggregate query aggregate_query = query.aggregate_query .add_count aggregate_query_results = dataset.run_aggregation aggregate_query puts aggregate_query_results.get
Methods
#get
def get(aggregate_alias = nil) -> Integer
Retrieves the aggregate data.
Parameter
- aggregate_alias (String) — The alias used to access the aggregate value. For an AggregateQuery with a single aggregate field, this parameter can be omitted.
Returns
Examples
- (Integer) — The aggregate value.
require "google/cloud/datastore" datastore = Google::Cloud::Datastore.new query = Google::Cloud::Datastore::Query.new query.kind("Task") .where("done", "=", false) Create an aggregate query aggregate_query = query.aggregate_query .add_count aggregate_query_results = dataset.run_aggregation aggregate_query puts aggregate_query_results.get
Alias an aggregate query
require "google/cloud/datastore" datastore = Google::Cloud::Datastore.new query = Google::Cloud::Datastore::Query.new query.kind("Task") .where("done", "=", false) Create an aggregate query aggregate_query = query.aggregate_query .add_count aggregate_alias: 'total' aggregate_query_results = dataset.run_aggregation aggregate_query puts aggregate_query_results.get('total')
#read_time
def read_time() ->
Read timestamp the query was done on the database at.
Returns
- — Google::Protobuf::Timestamp