0
votes

I want to auto generate ids in cloud datastore that doesn't exceed more than 7 digits in length.

In previous version of python cloud datastore library one was able to provide a max parameter to ensure that the auto generated id doesn't exceed a maximum limit. Ref: https://cloud.google.com/appengine/docs/standard/python/ndb/creating-entity-keys

Since now this feature has been removed from the latest python datastore library: Ref: https://googleapis.dev/python/datastore/latest/_modules/google/cloud/datastore/client.html#Client.key

How can one achieve the same ?

1

1 Answers

0
votes

There isn't a way to achieve that, unfortunately, in the newest version. As the official documentation confirms here, there isn't a replacement for the method max_allocate_ids_keys(), so it's not possible to limit the size of the id, which as you probably know, can be up to 16 digits.

If you find it useful, you can raise a Feature Request here, on Google's Issue Tracker, so they can check about possibly implementing a similar feature in new versions.