Google 多个数据存储 parents?

Google Datastore multiple parents?

一个实体可以有多个 parents 不排成一行,例如儿子->父亲->祖父吗?

示例:

家谱:妈妈和爸爸都是 parents 他们所有的 children。

不可以,一个实体只能有一个父实体。来自 Ancestor paths:

Entities in Cloud Datastore form a hierarchically structured space similar to the directory structure of a file system. When you create an entity, you can optionally designate another entity as its parent; the new entity is a child of the parent entity (note that unlike in a file system, the parent entity need not actually exist). An entity without a parent is a root entity. The association between an entity and its parent is permanent, and cannot be changed once the entity is created. Cloud Datastore will never assign the same numeric ID to two entities with the same parent, or to two root entities (those without a parent).

An entity's parent, parent's parent, and so on recursively, are its ancestors; its children, children's children, and so on, are its descendants. The sequence of entities beginning with a root entity and proceeding from parent to child, leading to a given entity, constitute that entity's ancestor path. The complete key identifying the entity consists of a sequence of kind-identifier pairs specifying its ancestor path and terminating with those of the entity itself:

[User:alice, TaskList:default, Task:sampleTask]

For a root entity, the ancestor path is empty and the key consists solely of the entity's own kind and identifier:

[User:alice]

以下目录结构比较:一个文件只能存在于一个目录中,不能存在于两个以上。