- HTTP request
- Path parameters
- Request body
- Response body
- Authorization scopes
- QueryResultBatch
- ResultType
- Try it!
Queries for entities.
HTTP request
POST https://datastore.googleapis.com/v1/projects/{projectId}:runQuery
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
project |
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 |
---|
{ "databaseId": string, "partitionId": { object ( |
Fields | |
---|---|
database |
The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database. |
partition |
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. |
read |
The options for this query. |
property |
The properties to return. This field must not be set for a projection query. |
explain |
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. |
gql |
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 |
transaction |
The identifier of the transaction that was started as part of this projects.runQuery request. Set only when A base64-encoded string. |
explain |
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 | |
---|---|
skipped |
The number of results skipped, typically because of an offset. |
skipped |
A cursor that points to the position after the last skipped result. Will be set when A base64-encoded string. |
entity |
The result type for every entity in |
entity |
The results for this batch. |
end |
A cursor that points to the position after the last result in the batch. A base64-encoded string. |
more |
The state of the query after the current batch. |
snapshot |
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. |
read |
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. Uses RFC 3339, where generated output will always be Z-normalized and uses 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted.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. |