What is the difference between these queries:
With consequent filters:
qry1 = Account.query() # Retrieve all Account entitites
qry2 = qry1.filter(Account.userid >= 40) # Filter on userid >= 40
qry3 = qry2.filter(Account.userid < 50) # Filter on userid < 50 as well
Using ndb.OR:
qry = Article.query(ndb.OR(Account.userid >= 40,
Account.userid < 50))
Using ndb.AND:
qry = Article.query(ndb.AND(Account.userid >= 40,
Account.userid < 50))
The first query does an AND. Thus, only the entities that match both inequalities will be returned by the query. The second query does an OR. Thus, entities that match either of the filters will be returned. For more information about ndb queries, take a look at NDB Queries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With