在日期的gql查询 [英] gql query on date

查看:129
本文介绍了在日期的gql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何应用GQL查询,以便在过去3天内登录的用户的UserInformation模型表中列出user_name?

方案

我假设UserInformation是您自己的类,它不是我知道的任何App Engine模型的一部分,而您正在使用python。



您将无法仅返回user_name的列表,您将收到UserInformation模型实例的集合。



你的模型中有最后一个登录日期属性吗?

  three_days_ago = datetime.datetime.now() -  datetime.timedelta(days = 3 )
users = db.Query(UserInformation).filter(login_date>,three_days_ago).fetch(10)


How do I apply a GQL query such that it lists the user_name in the UserInformation model table of those who have logged in within the last 3 days?

解决方案

I am presuming UserInformation is your own class, it is not part of any App Engine model that I know and you are using python.

You won't be able to return just a list of user_names, you will get a collection of UserInformation model instances.

Do you have a last login date property in your model? If yes, then the following should work.

three_days_ago = datetime.datetime.now() - datetime.timedelta(days = 3)
users = db.Query(UserInformation).filter("login_date >", three_days_ago).fetch(10)

这篇关于在日期的gql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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