jeudi 4 octobre 2018

Firebase Database WEB Query a string not a number

I probably found a bug. My Goal is to query the child's, in which the location started with an input (searchLocationText (a number)). In my database, I quoted the number for the Location ("for example Location: "889878"). If I do the request, firebase query: finds every child, in which Location is greater than searchLocationText (for example 50). But the result should be: show me every child, in which Location started with the String "50". Thanks for your help.

if (searchLocationText != "") {
    window.alert(parseInt(searchLocationText.substring(0,2)));
    var query = rootRef.orderByChild("Location").startAt(String(searchLocationText.substring(0,2)));
    query.on("child_added", snap => {
        const location = snap.child("Location").val();
        const description = snap.child("Description").val();
        window.alert(dogName);
        updateSearchGrid(dogName);
    });
}

enter image description here

Aucun commentaire:

Enregistrer un commentaire