Reputation: 2656
I'm trying to find if an email already exists in my database when a user signs up. Right now I do:
email = "[email protected]"
existing_users = db.collection("users").where("email", '==', email).get()
if (len(list(existing_users)):
print("the user already exists")
Is there a better way to achieve the same results?
Upvotes: 0
Views: 492
Reputation: 598847
There is no specific query to check if a document exists in Cloud Firestore (although it does exist in Firestore's server-side security rules). The idiomatic approach is indeed to load the documents (either by ID or with a query) and check if there are any results.
Upvotes: 1