0
I need to do basic languages like this:
1) You will query Firebase, checking if there is a certain ID. If there is this ID, it will give . then saying that it is ok and do something, if it will not give . catch, stating the problem.
What I tried to do was this: But I don’t think I did it right.
this.queryMAP = () => {
//let userId = this.getDBSReference().currentUser.uid;
let mapRef = this.getDBSReference().ref('users/Aliansce/LOCATIONS/').orderByKey().equalTo('map1');
mapRef.on('child_added', (snap) => {
console.log(snap.key)
snap.key.this.createPromise()
});
this.createPromise = () => {
let promise = new Promise((resolve, reject) => {
console.log(snap.key)
if(snap.key == "map1"){
resolve("igual")
} else {
reject("diferente");
}
}).then((sucess) =>{
console.info("ae");
}).catch((err) => {
console.warn("error")
});
};
I think
.orderByKey().equalTo('map1')
is not the correct syntax not expensive. But from what I realized you want to find the object with the keymap1
. I’m posting my answer now– Rosário Pereira Fernandes