Quantcast
Channel: Jack @ ASP.NET » Python
Viewing all articles
Browse latest Browse all 8

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

$
0
0
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 all articles
Browse latest Browse all 8

Trending Articles