【发布时间】:2012-12-04 04:21:16
【问题描述】:
我正在尝试从 mongo 中进行选择(使用 pymongo),查询纪元时间戳。 我的数据库中的一个样本是(为简洁起见):
{
"_id": "",
"tweet": {
"iso_language_code": "en",
"to_user_name": null,
"timestamp": 1355325948,
"created_at": "Wed, 12 Dec 2012 15:25:48 +0000"
}
}
以及查询,在代码中和在 python 控制台中:
<console>
db.tweets.find({
"tweet.timestamp":{'$gte':1355391000},
"tweet.timestamp":{'$lte':1355414400}
})
<code>
cursor = db.tweets.find({"tweet.timestamp":{'$gte':startEpoch},
"tweet.timestamp":{'$lte':endEpoch}})
分别是 2012 年 12 月 13 日星期四 09:30:00 GMT 和 2012 年 12 月 13 日星期四 16:00:00 GMT。
应该说,给我所有的推文gte this int和lte this other int。然而,它返回一切——它似乎根本没有限制这些值。
例如返回此条目,时间戳为:1355325948 即:Wed, 12 Dec 2012 15:25:48 GMT
另外,我的理解是带有参数列表的 find(...) 是一个隐含的 AND。
太棒了!
【问题讨论】:
标签: python mongodb datetime pymongo epoch