问题
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