0

I want to update one property of each entity present in one particular kind of my datastore. In traditional sql, we do something like this as -

update <tablename> set <property> = <value>; {where clause is optional}

Now, how can I do same thing for datastore using golang code?

Aniruddha Dwivedi
  • 91
  • 1
  • 2
  • 13

1 Answers1

1

In Datastore you can't perform an update like that without retrieving the entities. You have to pull all entities in that kind, update the property on each, and re-upsert the now updated entities (preferably in a batch).

Go Datastore Queries: https://cloud.google.com/datastore/docs/concepts/queries#datastore-datastore-basic-query-go

Go Update Entities: https://cloud.google.com/datastore/docs/concepts/entities#datastore-datastore-update-go

Go Batch Upsert: https://cloud.google.com/datastore/docs/concepts/entities#datastore-datastore-batch-upsert-go

Zachary Raineri
  • 148
  • 1
  • 12