Reference documentation and code samples for the Firestore in Datastore mode V1 API class Google::Cloud::Datastore::V1::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.
(::Google::Cloud::Datastore::V1::PartitionId) — Entities are partitioned into subsets, currently identified by a project
ID and namespace ID.
Queries are scoped to a single partition.
value (::Google::Cloud::Datastore::V1::PartitionId) — Entities are partitioned into subsets, currently identified by a project
ID and namespace ID.
Queries are scoped to a single partition.
Returns
(::Google::Cloud::Datastore::V1::PartitionId) — Entities are partitioned into subsets, currently identified by a project
ID and namespace ID.
Queries are scoped to a single partition.
(::Array<::Google::Cloud::Datastore::V1::Key::PathElement>) — 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 a root entity, the second element identifies
a child of 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's ancestors.
An entity path is always fully complete: all of 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 of Mutation.insert may have no
identifier.
A path can never be empty, and a path can have at most 100 elements.
value (::Array<::Google::Cloud::Datastore::V1::Key::PathElement>) — 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 a root entity, the second element identifies
a child of 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's ancestors.
An entity path is always fully complete: all of 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 of Mutation.insert may have no
identifier.
A path can never be empty, and a path can have at most 100 elements.
Returns
(::Array<::Google::Cloud::Datastore::V1::Key::PathElement>) — 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 a root entity, the second element identifies
a child of 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's ancestors.
An entity path is always fully complete: all of 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 of Mutation.insert may 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,["# Firestore in Datastore mode V1 API - Class Google::Cloud::Datastore::V1::Key (v1.4.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.4.1 (latest)](/ruby/docs/reference/google-cloud-datastore-v1/latest/Google-Cloud-Datastore-V1-Key)\n- [1.4.0](/ruby/docs/reference/google-cloud-datastore-v1/1.4.0/Google-Cloud-Datastore-V1-Key)\n- [1.3.1](/ruby/docs/reference/google-cloud-datastore-v1/1.3.1/Google-Cloud-Datastore-V1-Key)\n- [1.2.0](/ruby/docs/reference/google-cloud-datastore-v1/1.2.0/Google-Cloud-Datastore-V1-Key)\n- [1.1.0](/ruby/docs/reference/google-cloud-datastore-v1/1.1.0/Google-Cloud-Datastore-V1-Key)\n- [1.0.1](/ruby/docs/reference/google-cloud-datastore-v1/1.0.1/Google-Cloud-Datastore-V1-Key)\n- [0.19.0](/ruby/docs/reference/google-cloud-datastore-v1/0.19.0/Google-Cloud-Datastore-V1-Key)\n- [0.18.0](/ruby/docs/reference/google-cloud-datastore-v1/0.18.0/Google-Cloud-Datastore-V1-Key)\n- [0.17.0](/ruby/docs/reference/google-cloud-datastore-v1/0.17.0/Google-Cloud-Datastore-V1-Key)\n- [0.16.3](/ruby/docs/reference/google-cloud-datastore-v1/0.16.3/Google-Cloud-Datastore-V1-Key)\n- [0.15.0](/ruby/docs/reference/google-cloud-datastore-v1/0.15.0/Google-Cloud-Datastore-V1-Key)\n- [0.14.0](/ruby/docs/reference/google-cloud-datastore-v1/0.14.0/Google-Cloud-Datastore-V1-Key)\n- [0.13.1](/ruby/docs/reference/google-cloud-datastore-v1/0.13.1/Google-Cloud-Datastore-V1-Key)\n- [0.12.0](/ruby/docs/reference/google-cloud-datastore-v1/0.12.0/Google-Cloud-Datastore-V1-Key)\n- [0.11.1](/ruby/docs/reference/google-cloud-datastore-v1/0.11.1/Google-Cloud-Datastore-V1-Key)\n- [0.10.0](/ruby/docs/reference/google-cloud-datastore-v1/0.10.0/Google-Cloud-Datastore-V1-Key)\n- [0.9.0](/ruby/docs/reference/google-cloud-datastore-v1/0.9.0/Google-Cloud-Datastore-V1-Key)\n- [0.8.0](/ruby/docs/reference/google-cloud-datastore-v1/0.8.0/Google-Cloud-Datastore-V1-Key)\n- [0.7.0](/ruby/docs/reference/google-cloud-datastore-v1/0.7.0/Google-Cloud-Datastore-V1-Key)\n- [0.6.0](/ruby/docs/reference/google-cloud-datastore-v1/0.6.0/Google-Cloud-Datastore-V1-Key)\n- [0.5.0](/ruby/docs/reference/google-cloud-datastore-v1/0.5.0/Google-Cloud-Datastore-V1-Key)\n- [0.4.0](/ruby/docs/reference/google-cloud-datastore-v1/0.4.0/Google-Cloud-Datastore-V1-Key)\n- [0.3.5](/ruby/docs/reference/google-cloud-datastore-v1/0.3.5/Google-Cloud-Datastore-V1-Key) \nReference documentation and code samples for the Firestore in Datastore mode V1 API class Google::Cloud::Datastore::V1::Key.\n\nA unique identifier for an entity.\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\nInherits\n--------\n\n- Object \n\nExtended By\n-----------\n\n- Google::Protobuf::MessageExts::ClassMethods \n\nIncludes\n--------\n\n- Google::Protobuf::MessageExts\n\nMethods\n-------\n\n### #partition_id\n\n def partition_id() -\u003e ::Google::Cloud::Datastore::V1::PartitionId\n\n**Returns**\n\n- ([::Google::Cloud::Datastore::V1::PartitionId](./Google-Cloud-Datastore-V1-PartitionId)) --- Entities are partitioned into subsets, currently identified by a project ID and namespace ID. Queries are scoped to a single partition.\n\n### #partition_id=\n\n def partition_id=(value) -\u003e ::Google::Cloud::Datastore::V1::PartitionId\n\n**Parameter**\n\n- **value** ([::Google::Cloud::Datastore::V1::PartitionId](./Google-Cloud-Datastore-V1-PartitionId)) --- Entities are partitioned into subsets, currently identified by a project ID and namespace ID. Queries are scoped to a single partition. \n**Returns**\n\n- ([::Google::Cloud::Datastore::V1::PartitionId](./Google-Cloud-Datastore-V1-PartitionId)) --- Entities are partitioned into subsets, currently identified by a project ID and namespace ID. Queries are scoped to a single partition.\n\n### #path\n\n def path() -\u003e ::Array\u003c::Google::Cloud::Datastore::V1::Key::PathElement\u003e\n\n**Returns**\n\n- (::Array\\\u003c[::Google::Cloud::Datastore::V1::Key::PathElement](./Google-Cloud-Datastore-V1-Key-PathElement)\\\u003e) --- 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 a *root entity* , the second element identifies a *child* of 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's *ancestors* .\n\n\n An entity path is always fully complete: *all* of the entity's ancestors\n are required to be in the path along with the entity identifier itself.\n The only exception is that in some documented cases, the identifier in the\n last path element (for the entity) itself may be omitted. For example,\n the last path element of the key of `Mutation.insert` may have no\n identifier.\n\n A path can never be empty, and a path can have at most 100 elements.\n\n### #path=\n\n def path=(value) -\u003e ::Array\u003c::Google::Cloud::Datastore::V1::Key::PathElement\u003e\n\n**Parameter**\n\n- **value** (::Array\\\u003c[::Google::Cloud::Datastore::V1::Key::PathElement](./Google-Cloud-Datastore-V1-Key-PathElement)\\\u003e) --- 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 a *root entity* , the second element identifies a *child* of 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's *ancestors* .\n\n\n An entity path is always fully complete: *all* of the entity's ancestors\n are required to be in the path along with the entity identifier itself.\n The only exception is that in some documented cases, the identifier in the\n last path element (for the entity) itself may be omitted. For example,\n the last path element of the key of `Mutation.insert` may have no\n identifier.\n\nA path can never be empty, and a path can have at most 100 elements. \n**Returns**\n\n- (::Array\\\u003c[::Google::Cloud::Datastore::V1::Key::PathElement](./Google-Cloud-Datastore-V1-Key-PathElement)\\\u003e) --- 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 a *root entity* , the second element identifies a *child* of 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's *ancestors* .\n\n\n An entity path is always fully complete: *all* of the entity's ancestors\n are required to be in the path along with the entity identifier itself.\n The only exception is that in some documented cases, the identifier in the\n last path element (for the entity) itself may be omitted. For example,\n the last path element of the key of `Mutation.insert` may have no\n identifier.\n\n A path can never be empty, and a path can have at most 100 elements."]]