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

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

问题描述

这些查询有什么区别:

  1. 带有后续过滤器:

  1. 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

  • 使用 ndb.OR:

  • Using ndb.OR:

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

  • 使用 ndb.AND:

  • Using ndb.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天全站免登陆