How to look up the entries added to a table in last 5 seconds using Pymongo in python for mongodb
Question: I require to look up the entries added to my mongodb collection which were
created or added in the past 10 seconds .

At present I do not have timestamp as part of the documents i have inserted
into the collection. By reading stuff off google I understood that I can do
this somehow using hte object id but I did not understand exactly how can I do
it .


Answer: You could try:

    
    
    from datetime import datetime
    from bson.objectid import ObjectId
    
    newdate = datetime.utcnow() + timedelta(seconds=-10)
    dummy_id = ObjectId.from_datetime(newdate)
    
    result = collection.find( { "_id": { "$gt": dummy_id } } )
    

