Answer the question
In order to leave comments, you need to log in
MongoDB pymongo how to display records in descending order?
How to display entries in descending order? In sql it's like this: SELECT* FROM posts ORDER BY id DESC. And how is this implemented in MongoDB pymongo?
Answer the question
In order to leave comments, you need to log in
from pymongo import MongoClient, ASCENDING, DESCENDING
con = MongoClient('localhost:27017')
for x in con.db.collection.find( {'field' : 'value'} ).sort([('student_id', ASCENDING)]):
print x
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question