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.
精彩评论