是否可以在包含键列表(值)的 属性 上 运行 一个“HAS ANCESTOR”filter/query
Is it possible to run an ' HAS ANCESTOR' filter/query on a property that contains a list(Value) of keys
我有一种 client
由具有 属性 psets
的实体组成,其中包含 Key
的列表
使用 JSON api psets
这将表示为:
psets = { listValue: [ {keyValue: { path: [...]} },{keyValue: { path: [...]} },... ]}
键值由path = [{ kind: 'project', name: 'projectn' }]
组成
我正在尝试 运行 使用
在 'client' 上进行 'ancestor' 查询
SELECT * from client where psets HAS ANCESTOR KEY( project, 'project1')
这个查询returns一个错误:unsupported property
什么是不支持的?
如何 运行 对键列表进行 'HAS ANCESTOR' 过滤?
请注意根据DataStore Documentation(运算符和比较)
A condition can also test whether one entity has another entity as an ancestor, using the HAS ANCESTOR or HAS DESCENDANT operators. These operators test ancestor relationships between keys. They can operate on __key__, but they can also operate on a key-valued property. For HAS ANCESTOR, the right operand cannot be a property
(强调我的)
Datastore 仅支持实体键(即特殊的 __key__
属性)的 HAS ANCESTOR
运算符,而不支持常规键值。
一个可能的解决方法是明确地将每个祖先作为 属性 包含在实体中。
例如,如果您的 psets
属性 包含一个键 project:project1/foo:2/bar:3
,您可以维护一个单独的 psets_ancestors
列表 属性,其中包含 project:project1
、project:project1/foo:2
和 project:project1/foo:2/bar:3
。然后你可以在 psets_ancestors
属性:
上做相等查询
SELECT * FROM client WHERE psets_ancestors = KEY(project, 'project1')
(这是以额外的索引条目为代价的,并且必须维护单独的列表 属性。)
我有一种 client
由具有 属性 psets
的实体组成,其中包含 Key
使用 JSON api psets
这将表示为:
psets = { listValue: [ {keyValue: { path: [...]} },{keyValue: { path: [...]} },... ]}
键值由path = [{ kind: 'project', name: 'projectn' }]
我正在尝试 运行 使用
在 'client' 上进行 'ancestor' 查询SELECT * from client where psets HAS ANCESTOR KEY( project, 'project1')
这个查询returns一个错误:unsupported property
什么是不支持的?
如何 运行 对键列表进行 'HAS ANCESTOR' 过滤?
请注意根据DataStore Documentation(运算符和比较)
A condition can also test whether one entity has another entity as an ancestor, using the HAS ANCESTOR or HAS DESCENDANT operators. These operators test ancestor relationships between keys. They can operate on __key__, but they can also operate on a key-valued property. For HAS ANCESTOR, the right operand cannot be a property
(强调我的)
Datastore 仅支持实体键(即特殊的 __key__
属性)的 HAS ANCESTOR
运算符,而不支持常规键值。
一个可能的解决方法是明确地将每个祖先作为 属性 包含在实体中。
例如,如果您的 psets
属性 包含一个键 project:project1/foo:2/bar:3
,您可以维护一个单独的 psets_ancestors
列表 属性,其中包含 project:project1
、project:project1/foo:2
和 project:project1/foo:2/bar:3
。然后你可以在 psets_ancestors
属性:
SELECT * FROM client WHERE psets_ancestors = KEY(project, 'project1')
(这是以额外的索引条目为代价的,并且必须维护单独的列表 属性。)