在 Google Cloud Firestore 上创建自动增加文档 ID
Create Auto Increase Document ID on Google Cloud Firestore
我正在尝试使用与 Google Cloud Firestore 配合使用的 .NET Winforms 制作应用程序。我需要在其中创建集合和文档,但文档应该具有有序的 ID。例如;
- 数据库(集合)
- T1(文件)
- T2
- T3
如果我将文档添加到数据库集合,新文档 ID 应该是 T4。我可以获得所有收集数据并找到它的大小,但我认为这是最糟糕的解决方案。我该如何解决?
来自相关 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.
我正在尝试使用与 Google Cloud Firestore 配合使用的 .NET Winforms 制作应用程序。我需要在其中创建集合和文档,但文档应该具有有序的 ID。例如;
- 数据库(集合)
- T1(文件)
- T2
- T3
如果我将文档添加到数据库集合,新文档 ID 应该是 T4。我可以获得所有收集数据并找到它的大小,但我认为这是最糟糕的解决方案。我该如何解决?
来自相关 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.