开发者

Using List in GQL Filter

How can I make a selection in GQL using a List as filter.

I开发者_如何学JAVAf I have the class

public class Obj{

    @Persistent
    private Long name;

}

How can I get all Obj's that the name are not in a list?


You can get the results by chain all filters together.

SELECT * FROM User where email != 'xxx@gmail.com' and email != 'yyy@gmail.com' and email != 'zzz@gmail.com'

Python Code

q = User.all()
for i in ilist:
    q = q.filter("email = ", i)

But you may need to know there are some limitations for this kind of query.

Note: The IN and != operators use multiple queries behind the scenes. For example, the IN operator executes a separate underlying datastore query for every item in the list. The entities returned are a result of the cross-product of all the underlying datastore queries and are de-duplicated. A maximum of 30 datastore queries are allowed for any single GQL query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜