、あなたはドキュメントからdocumentatin https://firebase.google.com/docs/firestore/query-data/get-data
応じて、このように単一のドキュメントを検索することができます: -
次の例では、取得する方法を示していますGETを使用して、単一の文書の内容():
var docRef = db.collection("cities").doc("SF");
docRef.get().then(function(doc) {
if (doc.exists) {
console.log("Document data:", doc.data());
} else {
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});
の場合、次の操作を行うことができます。 -
const db = firebase.firestore()
db.collection('users')
.doc('currentUserID') // change to the current user id
.get().then((user)=>{
if(user.exists){
// now you can do something with user
console.log(user.data())
}
})