GQL 查询
当您更改应用引擎上的数据模型以添加新属性时,那些没有特定属性的条目会在在线数据查看器中列出,并带有值
。
我想知道如何编写查询来查找这些条目?
When you change data models on the app engine to add new properties those entries without a certain property are listed with the value <missing>
in the online data viewer.
What I'm wondering is how can I write a query to find those entries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有直接的方法来查询缺少属性的旧实体,但您可以预先设计数据模型来支持这一点。向每个模型类添加一个
version
属性。版本应该有一个默认值,每次更改和部署模型类时都会增加该默认值。这样您就可以按版本号查询实体。There is no direct way to query for older entities with missing attribute, but you can design data model upfront to support this. Add a
version
attribute to each model class. Version should have a default value, which is increased every time model class is changed and deployed. This way you will be able to query entities by version number.无法在数据存储中查询没有给定属性的实体。您需要迭代所有实体并检查每个实体 - 可能通过使用 mapreduce API。
There's no way to query the datastore for entities that don't have a given property. You need to iterate over all the entities and check each one - possibly by using the mapreduce API.
或者,您可以创建一个脚本,使用低级数据存储 API 将 null 粘贴到所有不具有该属性的当前项目中,这样您就可以查询 null。
我遇到了这个问题,这就是我解决它的方法。粗略的代码如下所示:
Or you could create a script to stick null in there for all current items that don't have that property using the low level datastore API, so then you can query on null.
I had this issue and that's how I solved it. The rough code would look like: