ubuntu@mongo1:~/pubnub-analytics$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymongo import Connection
>>> from pymongo import ASCENDING, DESCENDING
>>> conn = Connection()
>>> db = conn.pb2
>>> db.log_files.find_and_modify(
... query={'status':'unprocessed'},
... update={'$set':{}},
... sort=[('file_name',ASCENDING)],
... new=True)
{u'status': u'unprocessed', u'file_name':
u'2011-12-03_23:04:34.288091_50.18.36.76.log.bz2', u'_id':
ObjectId('4ee805931d011c644f003260')}
>>> db.log_files.find_one({'status':'unprocessed'})
{u'status': u'unprocessed', u'file_name':
u'2011-12-03_23:04:34.288091_50.18.36.76.log.bz2', u'_id':
ObjectId('4ee805931d011c644f003260')}
>>> db.log_files.find_one({'status':'unprocessed'}, sort=[('file_name',ASCENDING)])
{u'status': u'unprocessed', u'file_name':
u'2011-09-30_10:48:23.843037_46.137.255.217.log', u'_id':
ObjectId('4ee805981d011c644f00916c'), u'end_time':
datetime.datetime(2011, 12, 14, 2, 35, 52, 160000)}
1) find_and_modify while sorting by file_name and it returning a
file_name starting with 2011-12-03
2) a normal find with the same query, but without the sort returning
the same file_name starting with 2011-12-03
3) a find with the same query and WITH the sort and returning
2011-09-30.
2011-09-30 is what SHOULD be returned when sorting, but 2011-12-03 is
what is returned without sorting. 2011-12-03 is what is returned
during a find_and_modify (or update) even though I include the sort
parameter. Am I doing the sort wrong or could there be some other
issue involved?
Thanks,
On Dec 14, 4:21 pm, Zac Witte <zacwi...@gmail.com> wrote:
Zac