- HTTP request
- Path parameters
- Request body
- Response body
- Authorization scopes
- QueryResultBatch
- ResultType
- Try it!
Queries for entities.
HTTP request
POST https://datastore.googleapis.com/v1beta3/projects/{projectId}:runQuery
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
projectId |
Required. The ID of the project against which to make the request. |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "partitionId": { object ( |
Fields | |
---|---|
partitionId |
Entities are partitioned into subsets, identified by a partition ID. Queries are scoped to a single partition. This partition ID is normalized with the standard default context partition ID. |
readOptions |
The options for this query. |
propertyMask |
The properties to return. This field must not be set for a projection query. |
explainOptions |
Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned. |
Union field query_type . The type of query. query_type can be only one of the following: |
|
query |
The query to run. |
gqlQuery |
The GQL query to run. This query must be a non-aggregation query. |
Response body
The response for Datastore.RunQuery
.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{ "batch": { object ( |
Fields | |
---|---|
batch |
A batch of query results (always present). |
query |
The parsed form of the |
explainMetrics |
Query explain metrics. This is only present when the |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/datastore
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.
QueryResultBatch
A batch of results produced by a query.
JSON representation |
---|
{ "skippedResults": integer, "skippedCursor": string, "entityResultType": enum ( |
Fields | |
---|---|
skippedResults |
The number of results skipped, typically because of an offset. |
skippedCursor |
A cursor that points to the position after the last skipped result. Will be set when A base64-encoded string. |
entityResultType |
The result type for every entity in |
entityResults[] |
The results for this batch. |
endCursor |
A cursor that points to the position after the last result in the batch. A base64-encoded string. |
moreResults |
The state of the query after the current batch. |
snapshotVersion |
The version number of the snapshot this batch was returned from. This applies to the range of results from the query's In a single transaction, subsequent query result batches for the same query can have a greater snapshot version number. Each batch's snapshot version is valid for all preceding batches. The value will be zero for eventually consistent queries. |
readTime |
Read timestamp this batch was returned from. This applies to the range of results from the query's In a single transaction, subsequent query result batches for the same query can have a greater timestamp. Each batch's read timestamp is valid for all preceding batches. This value will not be set for eventually consistent queries in Cloud Datastore. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: |
ResultType
Specifies what data the 'entity' field contains. A ResultType
is either implied (for example, in LookupResponse.missing
from datastore.proto
, it is always KEY_ONLY
) or specified by context (for example, in message QueryResultBatch
, field entityResultType
specifies a ResultType
for all the values in field entityResults
).
Enums | |
---|---|
RESULT_TYPE_UNSPECIFIED |
Unspecified. This value is never used. |
FULL |
The key and properties. |
PROJECTION |
A projected subset of properties. The entity may have no key. |
KEY_ONLY |
Only the key. |