NDB querying results that start with a string

2019-05-11 12:45发布

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条回答
闹够了就滚
2楼-- · 2019-05-11 13:35

Try:

Kind.query(ndb.AND(Kind.property >= "abc", Kind.property <= "abcz"))
查看更多
登录 后发表回答