In order to effectively address your question, I would like to take a 
moment and explain the characteristics of a Entity 
<https://cloud.google.com/datastore/docs/concepts/entities>. Each entity 
within Datastore has a key that uniquely identifies it. The key (as you 
provided) consists of the following components: 

1. Namespace of the entity
2. The kind 
<https://cloud.google.com/datastore/docs/concepts/entities#kinds_and_identifiers>
 
of entity (categorized for queries)
3. An Identifier 
<https://cloud.google.com/datastore/docs/concepts/entities#kinds_and_identifiers>
 
for the individual entity (can be a key name string or a integer numeric 
id.)

I will be assuming that you are referring to the integer numeric id for 
your question. 

As far as having two of the same numeric ID's goes, indeed it is possible 
and this can be done by having your application assign their own numeric 
IDs manually to the entitles being created. However, as indicated in the 
documentation here 
<https://cloud.google.com/datastore/docs/concepts/entities#kinds_and_identifiers>,
 
"there is nothing to prevent a Datastore mode database from assigning one 
of your manual numeric IDs to another entity". You will have to implement 
the *allocateids() 
<https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/datastore/DatastoreService#allocateIds-java.lang.String-long->*method
 
within your application which will allow you to obtain a block of IDs in 
order to avoid the conflict mentioned above.

Also, since you mentioned that "Datastore is the one automatically 
generating the ids", the documentation found here 
<https://cloud.google.com/datastore/docs/concepts/entities#kinds_and_identifiers>
 states 
that the "automatic ID generator will keep track of IDs that have been 
allocated" and that Datastore "will avoid reusing them for another entity".

Therefore to sum it all up, Yes you can achieve the goal you want. However, 
it would be a good idea to implement the best practices for it as well such 
as: manually assigning Ids with implementing *allocateids() 
<https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/datastore/DatastoreService#allocateIds-java.lang.String-long->*
. 

I hope this helps!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/8cef0d63-0f78-44b0-838a-06edd79ed05f%40googlegroups.com.
  • [google-ap... NP
    • [goog... 'Harmit Rishi (Cloud Platform Support)' via Google App Engine
      • [... NP
        • ... 'Nicolas (Google Cloud Platform Support)' via Google App Engine
          • ... NP
            • ... 'Nicolas (Google Cloud Platform Support)' via Google App Engine

Reply via email to