How to compare two field of two queries in firestore? [closed]

心已入冬 提交于 2019-12-31 07:34:07

问题


I am developing a mobile application with ionic and firestore. I am stuck on the following point: When I make a query on a collection, I want to check if a field of this collection is equal to another field of another collection. I am new to this development, can someone please help me?

The code below is what I have tried but that does not work.

this.firestore.collection(`lignes`).get().toPromise().then((snapshot) => {
snapshot.docs.forEach(doc => {
this.numeroFav = doc.id;
console.log(this.numeroFav);
this.data = doc.data().userId;
console.log(this.data);
for (let a = 0; a < this.data.length; a++) {

    if (this.data[a].userId === this.userId) {
        this.dataStatus = this.data[a].status;
        if (this.dataStatus === true) {
            this.perturbationsBDD.subscribe((res) => {
                for (let i = 0; i < res.length; i++) {
                    console.log(this.numeroFav);
                    if (this.numeroFav === res[i].numero) {
                        this.isPerturbationsFavorite = true;
                        console.log(this.isPerturbationsFavorite);
                        this.perturbationsBDDFavorite.push({
                            icon: res[i].icon,
                            nomAgence: res[i].nomAgence,
                            numero: res[i].numero,
                            depart: res[i].depart,
                            horaireDepart: res[i].horaireDepart,
                            arrive: res[i].arrive,
                            horaireArrive: res[i].horaireArrive,
                            urlfacebook: res[i].urlfacebook,
                            tempsDeclaration: res[i].tempsDeclaration,
                            suppression: res[i].suppression,
                            retard: res[i].retard,
                            timeRetard: res[i].timeRetard,
                            vehiculeSurcharge: res[i].vehiculeSurcharge,
                            suggestion: res[i].suggestion,
                            securite: res[i].securite,
                            proprete: res[i].proprete,
                            commentaire: res[i].commentaire
                        });
                        console.log(this.perturbationsBDDFavorite);

                    }
                    console.log(this.perturbationsBDDFavorite);

                }
                console.log(this.perturbationsBDDFavorite);


            });
        }
    }
}
})
}) }

来源:https://stackoverflow.com/questions/59477085/how-to-compare-two-field-of-two-queries-in-firestore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!