英文:
2 or more users trying to upload the same data at the same time
问题
我正在尝试开发一个美发应用。但是当两个或更多用户同时尝试上传相同的数据(一个包含预约时间的字符串)时,我遇到了问题。如何确保只有其中一个用户上传数据?我正在使用Firebase(FireStore),以及在Android Studio中使用Java。
英文:
I'm trying to develop a hairdressing application. But i have a problem when two or more users try to upload the same data (a String with the appointment time) at the same time. How can I get only 1 of them to upload the data?. I´m using Firebase (FireStore) and Android Studio with Java.
答案1
得分: 2
你需要使用事务(transaction)来确保两个客户端应用不会覆盖彼此的更改。事务中的代码需要知道如何检查是否已经完成了工作,以及如果是这种情况应该做什么。
英文:
You will need to use a transaction to ensure that two client apps don't overwrite each other's changes. The code in the transaction will need to know how to check if work has already been done, and what to do if that's the case.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论