Home > Back-end >  How to wait until data is inserted into a mongodb timeseries collection?
How to wait until data is inserted into a mongodb timeseries collection?

Time:03-23

I am using Python 3.9 and MongoDB 5.0.6.

I have a function that has insert_many call inside. I want to wait until the data is inserted into the timeseries collection before return. How can I do that?

CodePudding user response:

By default pymongo is synchronous, so the insert_many() function call will not return until the data is inserted, so there's no specific need to wait.

This assumes you're not using the motor async driver or trying to read from a secondary replica.

  • Related