【发布时间】:2019-12-06 19:21:49
【问题描述】:
我有一个不断更新的“种类”,其中对象的父级是帐户。我想从此表中获取不同帐户的列表,其中每个帐户在过去 30 天内插入了最近的对象。
看来我不能对parent 或祖先使用投影查询。这基本上是我想要做的:
MyObject.query(default_options=QueryOptions(keys_only=True),projection=[MyObject.parent],
distinct=True).filter(MyObject.creation_date>= start)
我最终遇到以下错误:
AttributeError: type object 'MyObject' has no attribute 'parent'
有点预期,模型没有parent。 key 有一个父级。
有没有办法做到这一点?我知道投影查询有点像SELECT 语句来获取对象的特定属性,但是,这不是 sql,因为谷歌可能想让它看起来像它。我不认为这是一个复杂的查询......
【问题讨论】:
标签: google-cloud-datastore app-engine-ndb