我对编程非常陌生,想知道如何使我的 documentID = 我在 firestore 上的 UID
这是我的代码:
// create the user
Auth.auth().createUser(withEmail: Email, password: Password) { (results, Err) in
// check for errors
if Err != nil {
// there was an error creating the user
self.showError("Error creating user")
}
else {
// user was created succesfully store info
let db = Firestore.firestore()
db.collection("users").addDocument(data: ["first name":Firstname, "last name":Lastname, "age":Age, "uid":results!.user.uid]) { (Error) in
if Error != nil {
// show error message
self.showError("error saving user data")
}
Run Code Online (Sandbox Code Playgroud)
如果有人能告诉我需要在代码中添加什么,那就太棒了!
还有人知道我之后如何通过代码访问我的文档 …
firebase swift firebase-authentication google-cloud-firestore