Cloud Datastore Client - Class AggregationQueryResult (1.26.0)

Reference documentation and code samples for the Cloud Datastore Client class AggregationQueryResult.

Represents the result of an Aggregation Query

Example:

use Google\Cloud\Datastore\DatastoreClient;

$datastore = new DatastoreClient();

$query = $datastore->AggregationQuery();
$query->kind('Companies');
$query->filter('companyName', '=', 'Google');
$query->limit(100);
$query->addAggregation(Aggregation::count()->alias('total_upto_100'));

$res = $datastore->runAggregationQuery($query);
echo $res->get('total_upto_100');

Namespace

Google \ Cloud \ Datastore \ Query

Methods

__construct

Create AggregationQueryResult object.

Parameters
NameDescription
result array

Response of RunAggregationQuery

mapper Google\Cloud\Datastore\EntityMapper

[Optional] Entity mapper to map datastore values to their equivalent php values incase of null, NAN, INF and -INF

get

Get the Query Aggregation value.

Example:

$query = $datastore->AggregationQuery();
$query->kind('Companies');
$query->filter('companyName', '=', 'Google');
$query->addAggregation(Aggregation::count()->alias('total'));
$res = $client->runAggregationQuery($query);
echo $res->get('total');
Parameter
NameDescription
alias string

The aggregation alias.

Returns
TypeDescription
mixed

getQuery

Gets the value of query for example in case of a GqlQuery.

Returns
TypeDescription
Google\Cloud\Datastore\Query\AggregationQuery

getTransaction

Gets the transaction id when Aggregation is associated with a Transaction.

Returns
TypeDescription
string|null

getReadTime

Gets the timsstamp when Aggregation was executed.

Returns
TypeDescription
Google\Cloud\Core\Timestamp