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