marcelnicolay / mongotor

An asynchronous driver and toolkit for accessing MongoDB in Tornado
Other
57 stars 16 forks source link

positional element broken? #34

Open abdelouahabb opened 11 years ago

abdelouahabb commented 11 years ago

hi it seems that positional element is broken: in the console:

db.users.find_one({"reset.timr":"AgQGAAAGAQMfBgIdAgEQAQcMBAYIBgIeAgYGAAIG"}, {"reset.$.code":1}) Out[1]: {u'_id': u'abdelouahab_al@yahoo.fr', u'reset': [{u'code': u'2600', u'timr': u'AgQGAAAGAQMfBgIdAgEQAQcMBAYIBgIeAgYGAAIG'}]}

but:

code = yield tornado.gen.Task(db.users.find_one, ({"reset.timr":""AgQGAAAGAQMfBgIdAgEQAQcMBAYIBgIeAgYGAAIG""}, {"reset.$.timr":1})) i got: ([], None)

i tried to remove the positional element:

code = yield tornado.gen.Task(db.users.find_one, ({"reset.timr":tim}))

and i get the document, so as a hack i use:

code[0]["reset"][-1]

Edit: even $elemMatch gets None:

code = yield tornado.gen.Task(db.users.find, ({"reset.timr":tim}, {"reset":{"$elemMatch":{"timr":tim}}}))