'How can i make transection using .where

Since transaction only accepts DocumentReference so I couldn't handle the .where().

 DocumentReference test1=  FirebaseFirestore.instance.collection("users").doc(currentUser.uid);

Query<Map<String, dynamic>> test2=   FirebaseFirestore.instance.collection("users").where('test',isEqualTo: 'mytest').limit(1);

    return FirebaseFirestore.instance.runTransaction((transaction) async {

      //no problem with this DocumentSnapshot 
      DocumentSnapshot _value = await transaction.get(test1);
     

      //BUT
      //here in test2 will never accept Query<Map<String, dynamic>>
      //since the transaction is only accept DocumentReference 
      DocumentSnapshot _value2 = await transaction.get(test2);

      if (_value.exists) {
     //action
      }

    })

How can I get the .whereReference into the transaction?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source