How to sort mongodb with pymongo

前端 未结 7 1802
情书的邮戳
情书的邮戳 2020-11-28 04:01

I\'m trying to use the sort feature when querying my mongoDB, but it is failing. The same query works in the MongoDB console but not here. Code is as follows:



        
相关标签:
7条回答
  • 2020-11-28 04:49

    You can try this:

    db.Account.find().sort("UserName")  
    db.Account.find().sort("UserName",pymongo.ASCENDING)   
    db.Account.find().sort("UserName",pymongo.DESCENDING)  
    
    0 讨论(0)
提交回复
热议问题