[英]pymongo sort returning record that doesn't have the sorting key
我正在其日期列上對集合進行排序,以查找該集合中的最小日期。 但是,它為我返回了缺少日期鍵的記錄。 以下是代碼段。 這是錯誤嗎?
date_records = usercollection.find({'customer_id':'abc'}).sort('join_date',1).limit(1)
for record in date_records:
print record # prints a record that doesn't have the join_date key
print record['join_date']
輸出:
{ "_id" : ObjectId("94dbe4c6ea890e28113d7664"), "region" : "Virginia", "country_code" : "US", "customer_id" : "abc"}
KeyError: u'join_date'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.