GAE GQL - 如果列表包含项目,则获取实体 [英] GAE GQL - get entity if list contains item

查看:81
本文介绍了GAE GQL - 如果列表包含项目,则获取实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个带有StringListProperty的实体:'ids' - 一个与实体相关的id列表。然后我想通过询问给定的id是否在ID中来查询该实体。



我知道你可以使用filter

  q.filter(last_name IN,list)

但是我需要反过来,像这样:

  q.filter('id'IN ids)?? 

  q = db.GqlQuery(SELECT * FROM entity WHERE:1 IN IDS,ID)

https://developers.google.com/appengine/docs/python/数据存储/查询

解决方案

它只是 q.filter('id',id)


Say I've got an entity with a StringListProperty: 'ids' - a list of ids associated with the entity. I then want to query for that entity by asking if a given id is in ids.

I know you can use filter

q.filter("last_name IN", list)

but I need the reverse, something like:

q.filter('id' IN ids)??

or

q = db.GqlQuery("SELECT * FROM entity WHERE :1 IN ids", id)

https://developers.google.com/appengine/docs/python/datastore/queries

解决方案

It's just q.filter('ids', id).

这篇关于GAE GQL - 如果列表包含项目,则获取实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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