Check if user exists in Firestore

前端 未结 2 840
执念已碎
执念已碎 2020-12-12 02:30

I\'d like to create a users database in Cloud Firestore, with the email as the unique ID for each user. The users should be in a collection, and each user is a

相关标签:
2条回答
  • 2020-12-12 03:13

    The result of this Task is a DocumentSnapshot. Whether or not the underlying document actually exists is available via the exists method.

    If the document does exist you can call getData to get at the contents of it.

    0 讨论(0)
  • 2020-12-12 03:29

    Task result has a field named AdditionalUserInfo, you can find here isNewUser. it will return false if the user already exists.

      if (task.result?.additionalUserInfo!!.isNewUser){
             addNewUser()
        } else {
             updateUser()
      }
    
    0 讨论(0)
提交回复
热议问题