Quantcast
Viewing latest article 1
Browse Latest Browse All 8

sort and filter by objectid in mongo via python(pymongo)

for example, query collection that the ‘_id’ greater then the given objectid, and get the top 10 latest ones id = ObjectId('50b41c5670b35f4581f6df4f')sourceList = yourDB.Post.find({'_id':{'$gt': id}}).sort('_id', -1).limit(10);

Viewing latest article 1
Browse Latest Browse All 8

Trending Articles