I am building an API over my mongodb cluster. Each call for the API should return only the newest values or the values that have been modified seen the last call. I thought i need to add a field to each ducoment either representing the insertion timestamp or an auto incrementing field.
However, I am running in a highly distributed env.
I have many insertion pods the listen to a kafka topic and each is executing the following:
db.collection.bulk_write(operations)
Where operations is a list of ReplaceOne operations. Each containing the upsert=True key.
So i am afraid the if this new field is determined inside each pod, there might be concurrency issues.
Therefore, I am looking for this field to be generated inside my mongodb cluster. Is there any good way to do so?