How to make unique Timestamp within transaction or batch write

I’ve noticed many times that transaction or batch write with many documents at once creating documents with the same Timestamp .

How could i prevent that ?

>Solution :

This is actually by design, all writes in a transaction happen at the logically same time. There is no way to configure this behavior.

If you want each write to have a different timestamp you will have to pass a timestamp value from the client (instead of letting the server determine the value), or you will have to perform (some of) the writes outside of the transaction.

Leave a Reply