Closed grzegorz-it closed 6 years ago
The current code does not change the key type, it encodes the optional query parameters if it is not a number.
I will close the PR for now, but you have a sample test that demonstrate an issue with the actual code, we will consider it again.
Indeed this can happens for some ordering properties:
var r = base.getData("", { orderBy:"code", equalTo: code });
for
var code = "12345"; // no results
var code = "03456"; // Error: Constraint index field must be a JSON primitive
Exactly, if you put to equalTo a string containg number, this string will be converted to number and firebase will throw error:
getData("fbMessengerUsers", {"orderBy": "$key", "equalTo": "123"});
ERROR: "Key index passed non-string bound"
If you will use fix based on my pull request the string "123" will be not converted to number and it will work.
This is related to issue #3
I've has some problems with the merging, this will be fixed tomorrow.
It's important to do not change variable type while creating request. For example when you change type string to number you'll get error when searching by key because firebase do not allow keys to be numbers, it allow only strings.