'Fastest way to query the newest point in a pymongo time series collection?

I am relatively new to mongodb, and I am trying to query the newest point in a time series collection which is updated every few seconds. I am using:

with MongoClient(local_db) as client: 
    col = client['features']['binance-bookticker-5-ethusdt']
    res = col.find_one(sort=[('t', -1)])

This query indeed works and returns the last value. t is the timeField in my collection.

Is this the way that one would query in a time series collection?

Best



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source