多个过滤器vs OR,ndb查询 [英] multiple filters vs OR , ndb query

查看:151
本文介绍了多个过滤器vs OR,ndb查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些查询之间有什么不同:

what is the difference between these queries:

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

AND =>

qry = Article.query(ndb.OR(Account.userid >= 40,
                           Account.userid < 50))

AND =>

qry = Article.query(ndb.AND(Account.userid >= 40,
                            Account.userid < 50))


推荐答案

第一个查询执行AND操作。因此,只有匹配两个不等式的实体才会被查询返回。第二个查询执行OR操作。因此,匹配任一过滤器的实体将被返回。有关ndb查询的更多信息,请查看 NDB查询

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.

这篇关于多个过滤器vs OR,ndb查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆