title: prevent 2 users from reading the same id in Real Time Firebase database
body: <p>I have a real time database of firebase with this structure:</p>
  <p><a href="https://i.stack.imgur.com/EYCrg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EYCrg.png" alt="enter image description here" /></a></p>
  <p>In my app the user is given a <em>productId</em> randomly from <em>products</em> and at the same time the <em>productId</em> is deleted from <em>products</em> and inserted in <em>consumedProducts</em>, then he connects to the firestore with this id and makes changes to the object. The problem is that 2 users at the same time can get the same <em>productId</em> while in <em>products</em> if they access the same page at the same time. Instead I would like that if the first one gets an id , the second one will not get the same one but another one. How could I solve this problem? I have seen the use of transaction <a href="https://firebase.google.com/docs/database/web/read-and-write#save_data_as_transactions" rel="nofollow noreferrer">https://firebase.google.com/docs/database/web/read-and-write#save_data_as_transactions</a> but these are used only in case of writing in the same field</p>