繁体   English   中英

使用用户 uid 作为文档 id 将数据保存在 firestore 中,并能够检索和更新它

[英]Save data in firestore using user uid as document id and be able to retrieve and update it

我正在尝试使用用户 uid 作为文档 ID 将数据保存在 firestore 中,并且也能够检索和更新它

try {
  await createUserWithEmailAndPassword(
    auth,
    email,
    password
  ).then((userCredential) => {
    updateProfile(auth.currentUser, { displayName: username });
    toast.success('Account successfully created');
  
    auth.addDoc.collection("users").doc(userCredential.user.uid).set({
      username: username,
      email: email,
    })

使用 setDoc

   setDoc(doc(db, "users", userCredential.user.uid), {
              username: username,
              email: email,

              })

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM