App Engine:用于选择列表属性中存在特定项目的实体的过滤器
我需要根据存在某个元素的 ListProperties 之一来过滤实体。有点像:
Entity.filter('listProp IN ',element),除非 listProp 和 element 被颠倒,如果你明白我的意思的话。
有人知道如何这样过滤吗?
I need to filter entities based on one of their ListProperties having a certain element present. So kind of like:
entities.filter('listProp IN ',element) except where listProp and element are reversed if you see what I mean.
Anyone know how to filter like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确的话,您想要找到存在该特定元素的所有实体。您应该能够使用:entities.filter('listProp =', element)
查看:http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ListProperty
它表示,“list_property = value 测试该值是否出现在列表中的任何位置”。
If I understand you correctly, you want to find all entities which have that particular element present. You should be able to use: entities.filter('listProp =', element)
Look at: http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ListProperty
It says, "list_property = value tests if the value appears anywhere in the list".
好吧,事实证明 IN 相等子句会自动处理列表的这种情况。
正如它在要搜索的元素列表上执行 for ... every 一样,如果其中任何一个存在于每个实体的 ListProperty 中,它将返回该实体。
Ok so it turns out the IN equality clause takes care of this case for lists automatically.
As in it does a for ... each on the list of elements to be searched for and if any one of them is present in the ListProperty for each entity it will return that entity.