i am trying to validate if a user has already
liked a store before or not. if he did not it would add the data to the firestore collection, otherwise if he clicks again it would delete it.

right now everytime i click the button it adds a new document, i am not able to figure out how to delete the existing document if he clicks again.

```
@IBAction func tapFaveBtn(_ sender: Any) {

        let name = shopName.text!
        let address = detailedAdress.text!
        let table = numTable.text!
        let summaryS = summary.text!
        let timingS = timing.text!
        let userID = Auth.auth().currentUser!.uid

        db.collection("Favorites").whereField("shopPID", isEqualTo: getKey!).
        whereField("userID", isEqualTo: userID).
        getDocuments(){
                querySnapshot, error in
                if let error = error {
                    print(error.localizedDescription)
                }else
                {
                    if((querySnapshot!.isEmpty)){
                    self.db.collection("Favorites").addDocument(data:[
                    "ShopHeaderImg": self.headerImgURL!,
                    "ShopProfileImg":"",
                    "address": address,
                    "costEst": self.costEst.text!,
                    "country": "",
                    "latitude": self.getFinalLatitude!,
                    "location": self.location!,
                    "longitude": self.getFinalLongitude!,
                    "name": name,
                    "numTables": table,
                    "shopPID": self.getKey!,
                    "summary": summaryS,
                    "timing": timingS,
                    "usersID": userID,
                    ])
                   print("saved")

                    }else {
           for document in querySnapshot!.documents{
          document.reference.delete()
                  }
                    }
                }
                }
            }
    }

```

any help on this? thank you