App Engine NDB を使用して再帰構造をモデル化しようとしています。
class Root(ndb.Model):
pass
class Node(ndb.Model):
#Node can have either a Root, or another Node as parent
pass
root_key = Key(Root, 1)
node_a = Key(Root, 1, Node, 2)
node_b = Key(Root, 1, Node, 3)
node_a_a = Key(Root, 1, Node, 2, Node, 4)
ここから、直下の子のルート エンティティをクエリします。私ができることは、ルートのすべての子孫を照会することです。
Node.query(ancestor=root_key) # returns node_a, node_b, and node_a_a
私がやりたいことは次のとおりです。
Node.query(parent=root_key) # returns node_a, node_b
しかし、(即時の) 親キーによるクエリは、ndb API ではサポートされていないようです。うまくいけば、私は間違っています。解明が待ち遠しい。ありがとう