
本文介绍了实施“以...开始”和“结束”使用Google App Engine进行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有人可以提供一些关于如何实现一个使用Python的数据存储模型的查询开始或结束的指导?
在伪代码中,它... b $ p
$ b
查询所有实体A,其中属性P以X开头
或
查询属性P以X结尾的所有实体B
谢谢,Matt
'DIV CLASS = h2_lin>解决方案 您可以做一个使用不等式过滤查询 '开头':
MyModel.all()过滤器( '丙> =',前缀)。.filter( '丙<',前缀+ u'\\\�')
执行'以'结尾'查询需要存储字符串的反转,然后应用与上述相同的策略。
Am wondering if anyone can provide some guidance on how I might implement a starts with or ends with query against a Datastore model using Python?
In pseudo code, it would work something like...
Query for all entities A where property P starts with X
or
Query for all entities B where property P ends with X
Thanks, Matt
解决方案
You can do a 'starts with' query by using inequality filters:
MyModel.all().filter('prop >=', prefix).filter('prop <', prefix + u'\ufffd')
Doing an 'ends with' query would require storing the reverse of the string, then applying the same tactic as above.
这篇关于实施“以...开始”和“结束”使用Google App Engine进行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!