0
我想查询一个实体,但排除一堆键/ ID,我不想在结果中。这样做的最好方法是什么?ndb查询排除多个键或ID
我想也许.IN运营商会帮助我,但无法弄清楚如何。
于是我想出了以下解决方案链单键排除OP:
q = models.Comment.query()
for exclude_key in list_of_comment_keys_to_exclude:
q = q.filter(models.Comment.key != exclude_key)
q = q.order(models.Comment.key) # without this: BadRequestError: The first sort property must be the same as the property to which the inequality filter is applied.
q = q.order(models.Comment.creationTime)
这似乎是工作,但它是去它的好方法吗?
啊好吧谢谢Guido! – joplaete