user3787910
user3787910

Reputation: 313

How to specify property type when using Cloud Datastore API

I have this python code snippet for adding a new entity from Google Compute Engine. But this code results in userId being created with an undefined type. How can I specify the type of the property when it is getting created from compute engine?

kg = datastore.Entity(key)
try:
  kg.update({
    'userId': userId,
  })
  client.put(kg)

Upvotes: 0

Views: 223

Answers (1)

Ed Davisson
Ed Davisson

Reputation: 2927

gloud-python will infer the type of the property from the type of the value you place in the property map.

https://github.com/GoogleCloudPlatform/gcloud-python/blob/master/gcloud/datastore/helpers.py#L303

Upvotes: 2

Related Questions