正在查询应用程序引擎数据存储区中缺少属性的实体?
我有一个如下所示的模型:
class Example (db.Model) :
row_num = db.IntegerProperty(required=True)
updated = db.IntegerProperty()
...
...
现在,当我存储值时,我可能不会每次都填充更新属性的值,这意味着在某些实体中它可能不存在。
我想构造一个数据存储查询,以便我可以获得所有没有属性更新集的示例实体。
我该怎么做?
PS我知道我可以设置一个默认值,然后对其进行查询。但问题是我有超过 300 万个实体,并且仅标记其中 1% 的更新,因此我不想通过将其余实体设置为 0 来浪费如此多的数据存储空间。
I have a model which looks like this:
class Example (db.Model) :
row_num = db.IntegerProperty(required=True)
updated = db.IntegerProperty()
...
...
Now when i store values, I may not fill the value for the updated property every time, which implies that in some entities it may not exist.
I want to construct a datastore query so that i can get all entities of kind Example which do not have the property updated set.
How do i do this?
p.s. i know i can set a default value and then query on it. But the issue is i have over 3 million entities and updated will be marked only for 1% of them, so i do not want to waste so much of datastore space by setting the rest to 0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 GQL 中,没有属性值的对象无法通过对该属性的查询返回,因此如果没有默认值,您所要求的内容是不可能的。
参考:此页面。
In GQL, objects which do not have a value for a property cannot be returned by queries on that property, so what you're asking for is impossible without a default value.
Reference: section headed "Entities Without a Filtered Property Are Never Returned by a Query" on this page.