Are there advantages to storing Keys over String in Google App Engine datastore.
For example:
class Model(ndb.Model):
user_key = ndb.KeyProperty()
VS
class Model(ndb.Model):
user_id = ndb.StringProperty()
If you're using entity groups (ancestors), the KeyProperty will support that. When storing the id, unless the model who's id you're storing is the entity group root, you'll need to store enough info reconstruct the full key.
The KeyProperty will take more space, since it is storing additional data, but it may be more convenient to use when retrieving the other entity. Query speed should be comparable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With