I'm trying to make an app with .NET Winforms that work with Google Cloud Firestore. I need to create collection and documents in it but documents should have to ordered IDs. For example;
- Database (collection)
- T1 (document)
- T2
- T3
If i add a document to Database collection, new document id should be T4. I can get all collection data and find size of it but i think it's the worst solution. How can i solve it?
CodePudding user response:
From a related question, there is no built-in way of creating auto-incrementing IDs for documents, so this functionality should be implemented manually. Your current solution is one of the recommended methods of achieving this, but there is a scalability problem as updating the document ID, or count of documents to be used in generating the ID is limited to one update per second. If your application exceeds this rate of document creation (and therefore needing to update the latest document ID), you should implement document counter sharding.