Back

Check if username is taken

  • 1
  • Databases
  • Flutter
  • Cloud
tom
25 Jan, 2024, 05:46

What are some guiding principles to check whether or not a username is taken? I have a usersCollection, which stores various attributes about each user, including their username. When a new user joins our platform, I want to check if their username already exists in the collection. To do this, I need to return a list of all the username attributes for all the documents in my usersCollection, then check if the inputted username is in that list. I worry that means every user must be granted access to ever usersCollection document to construct that list in the first place.

Is this solved with a cloud function?

TL;DR
The developer wants to check if a username is taken by comparing it with the usernames in a usersCollection. They are wondering if granting access to all usersCollection documents is necessary in order to construct a list of usernames for comparison. They are also asking if this can be solved with a cloud function. Solution: One possible solution is to use a cloud function to perform the check. Instead of granting access to all usersCollection documents, you can write a cloud function that queries the usersCollection and returns a list of usernames. Then, you can compare the inputted username with this list in the cloud function itself and return the result. This way,
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more