This is my code:
func checkIfExist(property: String, isEqualTo: Any) -> Bool {
let query = db.collection("users").whereField(property, isEqualTo: isEqualTo)
query.getDocuments { (snapshot, error) in
guard let snapshot = snapshot?.documents else { print(error!); return }
print("There is \(snapshot.count) items.")
if snapshot.count == 1 {
return true
} else {
return false
}
}
}
Xcode is yelling errors and I understand why, but I don't know how to fix it. How do I return something in this case? Should I use a library like PromiseKit? Thanks.