且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android Firestore搜索集合,其中文档是唯一ID

更新时间:2023-02-14 09:28:20

您将查询名称:

var peopleRef = db.collection("users");
// there may multiple users if there are more then one `John Doe`
peopleRef.where("name", "==", "John Doe")
.get()
.then(function(querySnapshot) {
    querySnapshot.forEach(function(doc) {
        //Here below will list all people who's name = "John Doe", If only one then this John Doe's  id no: doc.id as fallow:
        console.log(doc.id, " => ", doc.data());
    });
})
.catch(function(error) {
    console.log("Error getting documents: ", error);
});