更新数据存储实体-在不更改实体密钥的情况下更改祖先

Is it possible to update the ancestor of an entity without changing the entity key? How would I accomplish that in Go?

I have a hierarchy similar to this:

Company/Department/Employee

It started off with no department for the employee: Company/Employee. Then later when he/she gets assigned to a department, I want to change it to: Company/Department/Employee, but I want the entity key to remain the same as it is already used elsewhere to reference this entity.

Is it possible to update the ancestor of an entity without changing the entity key?

I don't believe so. The ancestor is part of the key.

How would I accomplish that in Go?

Do you need to use an Entity Group here? I try to avoid entity group whenever possible. They add too many restrictions. I would suggest that you add properties to your Employee entity for Company and Department:

type Employee struct {
  Company, Department string
}

You can still query by these properties, although there maybe a few second delay after they are updated. If you need strong consistency you can always look the Employee up by Key. That will always return the most uptodate version.