NDB querying results that start with a string

依然范特西╮ 提交于 2019-12-10 10:21:00

问题


Working with Google App Engine's NDB, I'm looking to query for all items that start with a user-inputted string. Example:

abc_123
abcdefg
123abc

Querying for "abc" should return abc_123, abcdefg (however, not 123abc as it doesn't start with "abc")

I previously used the code below for a similar but different purpose:

q = q.filter(order._properties[kw].IN(values_list))

which filtered for all values in values_list that were in kw, I am now looking to filter for all values that start with a string that are in kw.


回答1:


Try:

Kind.query(ndb.AND(Kind.property >= "abc", Kind.property <= "abcz"))


来源:https://stackoverflow.com/questions/17702958/ndb-querying-results-that-start-with-a-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!