下面的这组查询将一组配置文件连接在一起,以返回到一个网站
我想用它们做一个查询,因为我想对整个概要文件集合使用order函数
# Get all users for who 'currentUser' is an assistant for.
users = Users.query(Users.assistant.IN(currentUser)).fetch()
# Get all profiles that belong to those users and have not been deleted.
for user in users:
profiles = profiles + Profiles.query(
ndb.AND(
Profiles.user == user.username,
Profiles.deleted == False
)
).order(Profiles.history).fetch() # Order all profiles by timestamp
在某种程度上,你所寻找的将相当于:
但是,如果
usernames
包含许多元素(显然超过10个左右),则会出现性能问题,请参见Does the NDB membership query ("IN" operation) performance degrade with lots of possible values?相关问题 更多 >
编程相关推荐