Queries for entities.
Scopes
You will need authorization for at least one of the following scopes to make a valid call:
- https://www.googleapis.com/auth/cloud-platform
- https://www.googleapis.com/auth/datastore
If unset, the scope for this method defaults to https://www.googleapis.com/auth/cloud-platform.
You can set the scope for this method like this: datastore1 --scope <scope> projects run-query ...
Required Scalar Argument
- <project-id> (string)
- Required. The ID of the project against which to make the request.
Required Request Value
The request value is a data-structure with various fields. Each field may be a simple scalar or another data-structure. In the latter case it is advised to set the field-cursor to the data-structure's field to specify values more concisely.
For example, a structure like this:
RunQueryRequest:
database-id: string
gql-query:
allow-literals: boolean
query-string: string
partition-id:
database-id: string
namespace-id: string
project-id: string
query:
end-cursor: string
filter:
composite-filter:
op: string
property-filter:
op: string
property:
name: string
value:
blob-value: string
boolean-value: boolean
double-value: number
entity-value:
key:
partition-id:
database-id: string
namespace-id: string
project-id: string
exclude-from-indexes: boolean
geo-point-value:
latitude: number
longitude: number
integer-value: string
key-value:
partition-id:
database-id: string
namespace-id: string
project-id: string
meaning: integer
null-value: string
string-value: string
timestamp-value: string
limit: integer
offset: integer
start-cursor: string
read-options:
new-transaction:
read-only:
read-time: string
read-write:
previous-transaction: string
read-consistency: string
read-time: string
transaction: string
can be set completely with the following arguments which are assumed to be executed in the given order. Note how the cursor position is adjusted to the respective structures, allowing simple field names to be used most of the time.
-r . database-id=lorem
- The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
gql-query allow-literals=true
- When false, the query string must not contain any literals and instead must bind all values. For example,
SELECT * FROM Kind WHERE a = 'string literal'
is not allowed, whileSELECT * FROM Kind WHERE a = @value
is.
- When false, the query string must not contain any literals and instead must bind all values. For example,
-
query-string=ipsum
- A string of the format described here.
-
..partition-id database-id=accusam
- If not empty, the ID of the database to which the entities belong.
namespace-id=takimata
- If not empty, the ID of the namespace to which the entities belong.
-
project-id=consetetur
- The ID of the project to which the entities belong.
-
..query end-cursor=voluptua.
- An ending point for the query results. Query cursors are returned in query result batches and can only be used to limit the same query.
-
filter.composite-filter op=et
- The operator for combining multiple filters.
-
..property-filter op=erat
- The operator to filter by.
-
property name=consetetur
- A reference to a property. Requires: * MUST be a dot-delimited (
.
) string of segments, where each segment conforms to entity property name limitations.
- A reference to a property. Requires: * MUST be a dot-delimited (
-
..value blob-value=amet.
- A blob value. May have at most 1,000,000 bytes. When
exclude_from_indexes
is false, may have at most 1500 bytes. In JSON requests, must be base64-encoded.
- A blob value. May have at most 1,000,000 bytes. When
boolean-value=true
- A boolean value.
double-value=0.8484298131719972
- A double value.
entity-value.key.partition-id database-id=et
- If not empty, the ID of the database to which the entities belong.
namespace-id=accusam
- If not empty, the ID of the namespace to which the entities belong.
-
project-id=voluptua.
- The ID of the project to which the entities belong.
-
.... exclude-from-indexes=false
- If the value should be excluded from all indexes including those defined explicitly.
geo-point-value latitude=0.7753213022845796
- The latitude in degrees. It must be in the range [-90.0, +90.0].
-
longitude=0.05043422241780038
- The longitude in degrees. It must be in the range [-180.0, +180.0].
-
.. integer-value=invidunt
- An integer value.
key-value.partition-id database-id=no
- If not empty, the ID of the database to which the entities belong.
namespace-id=est
- If not empty, the ID of the namespace to which the entities belong.
-
project-id=at
- The ID of the project to which the entities belong.
-
... meaning=58
- The
meaning
field should only be populated for backwards compatibility.
- The
null-value=sit
- A null value.
string-value=et
- A UTF-8 encoded string value. When
exclude_from_indexes
is false (it is indexed) , may have at most 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
- A UTF-8 encoded string value. When
-
timestamp-value=tempor
- A timestamp value. When stored in the Datastore, precise only to microseconds; any additional precision is rounded down.
-
.... limit=69
- The maximum number of results to return. Applies after all other constraints. Optional. Unspecified is interpreted as no limit. Must be >= 0 if specified.
offset=96
- The number of results to skip. Applies before limit, but after all other constraints. Optional. Must be >= 0 if specified.
-
start-cursor=et
- A starting point for the query results. Query cursors are returned in query result batches and can only be used to continue the same query.
-
..read-options.new-transaction.read-only read-time=sanctus
- Reads entities at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
-
..read-write previous-transaction=lorem
- The transaction identifier of the transaction being retried.
-
... read-consistency=est
- The non-transactional read consistency to use.
read-time=sed
- Reads entities as they were at the given time. This value is only supported for Cloud Firestore in Datastore mode. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
transaction=diam
- The identifier of the transaction in which to read. A transaction identifier is returned by a call to Datastore.BeginTransaction.
About Cursors
The cursor position is key to comfortably set complex nested structures. The following rules apply:
- The cursor position is always set relative to the current one, unless the field name starts with the
.
character. Fields can be nested such as in-r f.s.o
. - The cursor position is set relative to the top-level structure if it starts with
.
, e.g.-r .s.s
- You can also set nested fields without setting the cursor explicitly. For example, to set a value relative to the current cursor position, you would specify
-r struct.sub_struct=bar
. - You can move the cursor one level up by using
..
. Each additional.
moves it up one additional level. E.g....
would go three levels up.
Optional Output Flags
The method's return value a JSON encoded structure, which will be written to standard output by default.
- -o out
- out specifies the destination to which to write the server's result to.
It will be a JSON-encoded structure.
The destination may be
-
to indicate standard output, or a filepath that is to contain the received bytes. If unset, it defaults to standard output.
- out specifies the destination to which to write the server's result to.
It will be a JSON-encoded structure.
The destination may be
Optional General Properties
The following properties can configure any call, and are not specific to this method.
-
-p $-xgafv=string
- V1 error format.
-
-p access-token=string
- OAuth access token.
-
-p alt=string
- Data format for response.
-
-p callback=string
- JSONP
-
-p fields=string
- Selector specifying which fields to include in a partial response.
-
-p key=string
- API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
-
-p oauth-token=string
- OAuth 2.0 token for the current user.
-
-p pretty-print=boolean
- Returns response with indentations and line breaks.
-
-p quota-user=string
- Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
-
-p upload-type=string
- Legacy upload protocol for media (e.g. "media", "multipart").
-
-p upload-protocol=string
- Upload protocol for media (e.g. "raw", "multipart").