title: in Cloud Firestore transaction how Check to see if a Document exists in a specific Collection if we don't know Document name
body: <p>in cloud firestore transactions how can we find out if a document exists in a Collection when we just know a field name and its value and not the document name itself ?</p>
  
  <p>*i know the Collection name</p>
  
  <p>*i do <strong>not</strong> know the document name</p>
  
  <p>*i know the field_name and field_value that i'm looking for</p>
  
  <p>for example if i were not in transactions i could do it in the below way in python</p>
  
  <pre><code>def if_Exists(self):
      db = firestore.client()
      docs = db.collection(u'cities').where(u'field_name', u'==', 'field_value').get()
  
      for doc in docs:
          if bool(doc.to_dict()):
              return True
          return False
  </code></pre>
  
  <p>but in transactions for example in the below code sample(from Google docs) i don't know how can i use the where method(that i used in if_Exists() method)</p>
  
  <pre><code>transaction = db.transaction()
  city_ref = db.collection(u'cities').document(u'SF')
  
  @firestore.transactional
  def update_in_transaction(transaction, city_ref):
      snapshot = city_ref.get(transaction=transaction)
      transaction.update(city_ref, {
          u'population': snapshot.get(u'population') + 1
      })
  
  update_in_transaction(transaction, city_ref)
  </code></pre>
  
  <p>maybe the only way is to change my document names to my field values but i wanted to make sure that if its the only way ?
  Thank You</p>
  
  <p><strong>Edit for more detail:</strong>
  actually i wanted to only check if that document exists or not so i can prevent adding duplicate ones in my transaction. if i do it outside my transaction which i already did it. it does not work. </p>
  
  <p>for example if i run my transaction from two computer at the same time finally i got duplicate documents in my collection with the same field_name and field_value. i thought i could solve this problem with doing query in transaction and return from transaction if i already had that document. </p>
  
  <p>so as Doug Stevenson said its impossible so i'm curious why is the exact restriction that makes its impossible to have this feature in firestore ? is it impossible in SQL databases too ? is querying in transaction breaking an important rule or something ?</p>