ฉันกำลังพยายามสมัครและบันทึกข้อมูลผู้ใช้ลงใน firestore การดำเนินการบันทึกเป็นเรื่องปกติ แต่ฉันต้องการค้นหาข้อมูลนั้น แต่ไม่มีอะไรเกิดขึ้น นี่คือรหัสของฉัน
ลงชื่อ
firestore
.collection("users")
.doc(user.userId)
.collection("profile")
.add({ ...user })
.then(() => {
auth.onAuthStateChanged((u) => {
if (u) {
u.updateProfile({
displayName: user.displayName,
});
}
});
});
ดึงข้อมูลผู้ใช้ทั้งหมด
firestore
.collection("users")
.get()
.then(function (querySnapshot) {
querySnapshot.forEach(function (doc) {
//doc.data() is never undefined for query doc snapshots
console.log(doc.id, " => ", doc.data());
});
});