エンティティのクエリを実行したいが、結果に含めたくない一連のキー/ID を除外します。これを行う最善の方法は何ですか?
おそらく .IN 演算子が役立つだろうと思っていましたが、その方法がわかりませんでした。
そこで、単一のキーの除外をチェーンする次のソリューションを使用しました。
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 )
これは機能しているように見えますが、それについてうまくいく方法はありますか?