Reference documentation and code samples for the Cloud Datastore V1 Client class Key.
A unique identifier for an entity.
If a key's partition ID or any of its path kinds or names are
reserved/read-only, the key is reserved/read-only.
A reserved/read-only key is forbidden in certain documented contexts.
Generated from protobuf messagegoogle.datastore.v1.Key
The entity path. An entity path consists of one or more elements composed of a kind and a string or numerical identifier, which identify entities. The first element identifies aroot entity, the second element identifies achildof the root entity, the third element identifies a child of the second entity, and so forth. The entities identified by all prefixes of the path are called the element'sancestors. An entity path is always fully complete:allof the entity's ancestors are required to be in the path along with the entity identifier itself. The only exception is that in some documented cases, the identifier in the last path element (for the entity) itself may be omitted. For example, the last path element of the key ofMutation.insertmay have no identifier. A path can never be empty, and a path can have at most 100 elements.
getPartitionId
Entities are partitioned into subsets, currently identified by a project
ID and namespace ID.
An entity path consists of one or more elements composed of a kind and a
string or numerical identifier, which identify entities. The first
element identifies aroot entity, the second element identifies
achildof the root entity, the third element identifies a child of the
second entity, and so forth. The entities identified by all prefixes of
the path are called the element'sancestors.
An entity path is always fully complete:allof the entity's ancestors
are required to be in the path along with the entity identifier itself.
The only exception is that in some documented cases, the identifier in the
last path element (for the entity) itself may be omitted. For example,
the last path element of the key ofMutation.insertmay have no
identifier.
A path can never be empty, and a path can have at most 100 elements.
An entity path consists of one or more elements composed of a kind and a
string or numerical identifier, which identify entities. The first
element identifies aroot entity, the second element identifies
achildof the root entity, the third element identifies a child of the
second entity, and so forth. The entities identified by all prefixes of
the path are called the element'sancestors.
An entity path is always fully complete:allof the entity's ancestors
are required to be in the path along with the entity identifier itself.
The only exception is that in some documented cases, the identifier in the
last path element (for the entity) itself may be omitted. For example,
the last path element of the key ofMutation.insertmay have no
identifier.
A path can never be empty, and a path can have at most 100 elements.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Datastore V1 Client - Class Key (1.33.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.33.1 (latest)](/php/docs/reference/cloud-datastore/latest/V1.Key)\n- [1.33.0](/php/docs/reference/cloud-datastore/1.33.0/V1.Key)\n- [1.32.3](/php/docs/reference/cloud-datastore/1.32.3/V1.Key)\n- [1.31.0](/php/docs/reference/cloud-datastore/1.31.0/V1.Key)\n- [1.30.0](/php/docs/reference/cloud-datastore/1.30.0/V1.Key)\n- [1.29.2](/php/docs/reference/cloud-datastore/1.29.2/V1.Key)\n- [1.28.2](/php/docs/reference/cloud-datastore/1.28.2/V1.Key)\n- [1.26.0](/php/docs/reference/cloud-datastore/1.26.0/V1.Key)\n- [1.25.0](/php/docs/reference/cloud-datastore/1.25.0/V1.Key)\n- [1.24.4](/php/docs/reference/cloud-datastore/1.24.4/V1.Key)\n- [1.23.0](/php/docs/reference/cloud-datastore/1.23.0/V1.Key)\n- [1.22.1](/php/docs/reference/cloud-datastore/1.22.1/V1.Key)\n- [1.21.2](/php/docs/reference/cloud-datastore/1.21.2/V1.Key)\n- [1.19.0](/php/docs/reference/cloud-datastore/1.19.0/V1.Key)\n- [1.18.1](/php/docs/reference/cloud-datastore/1.18.1/V1.Key)\n- [1.17.1](/php/docs/reference/cloud-datastore/1.17.1/V1.Key) \nReference documentation and code samples for the Cloud Datastore V1 Client class Key.\n\nA unique identifier for an entity.\n\nIf a key's partition ID or any of its path kinds or names are\nreserved/read-only, the key is reserved/read-only.\nA reserved/read-only key is forbidden in certain documented contexts.\n\nGenerated from protobuf message `google.datastore.v1.Key`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Datastore \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getPartitionId\n\nEntities are partitioned into subsets, currently identified by a project\nID and namespace ID.\n\nQueries are scoped to a single partition.\n\n### hasPartitionId\n\n### clearPartitionId\n\n### setPartitionId\n\nEntities are partitioned into subsets, currently identified by a project\nID and namespace ID.\n\nQueries are scoped to a single partition.\n\n### getPath\n\nThe entity path.\n\nAn entity path consists of one or more elements composed of a kind and a\nstring or numerical identifier, which identify entities. The first\nelement identifies a *root entity* , the second element identifies\na *child* of the root entity, the third element identifies a child of the\nsecond entity, and so forth. The entities identified by all prefixes of\nthe path are called the element's *ancestors* .\nAn entity path is always fully complete: *all* of the entity's ancestors\nare required to be in the path along with the entity identifier itself.\nThe only exception is that in some documented cases, the identifier in the\nlast path element (for the entity) itself may be omitted. For example,\nthe last path element of the key of `Mutation.insert` may have no\nidentifier.\nA path can never be empty, and a path can have at most 100 elements.\n\n### setPath\n\nThe entity path.\n\nAn entity path consists of one or more elements composed of a kind and a\nstring or numerical identifier, which identify entities. The first\nelement identifies a *root entity* , the second element identifies\na *child* of the root entity, the third element identifies a child of the\nsecond entity, and so forth. The entities identified by all prefixes of\nthe path are called the element's *ancestors* .\nAn entity path is always fully complete: *all* of the entity's ancestors\nare required to be in the path along with the entity identifier itself.\nThe only exception is that in some documented cases, the identifier in the\nlast path element (for the entity) itself may be omitted. For example,\nthe last path element of the key of `Mutation.insert` may have no\nidentifier.\nA path can never be empty, and a path can have at most 100 elements."]]