Firebase Realtime equalTo不能与"+123"之类的String一起使用. [英] Firebase Realtime equalTo not working with String like "+123"
问题描述
我遇到问题,找不到答案.这是我的示例Firebase数据库,在移动"数据库上有一个索引.:
I have an issue and can't find the answer. Here is my sample firebase database, with an index on "mobile" :
test
A
mobile : "+1234567"
B
mobile : "+2345678"
现在我要查询所有具有mobile ="+1234567"的节点
Now I want to query all node with mobile = "+1234567"
test.json?orderBy="mobile"&equalTo="+1234567"
returns : { }
但是
test.json?orderBy="mobile"&startAt="+1234567"
returns :
{
"A" : {
"mobile" : "+1234567"
},
"B" : {
"mobile" : "+2345678"
}
}
和
test.json?orderBy="mobile"&startAt="+1234567"&endAt="+1234567"
returns : { }
怎么了?如果我删除所有"+"号,效果很好迹象(数据库+请求中)?!
What's wrong ? It works fine if I remove all "+" signs (in database + requests) ?!
推荐答案
您需要URL编码 +
字符,表示将其显示为%2B
.
You'll need to URL encode the +
character, meaning show it as %2B
.
所以:
test.json?orderBy="mobile"&startAt="+1234567"&endAt="%2B1234567"
在这里查看我的工作示例: https://stackoverflow.firebaseio.com/65924783.json?orderBy=%22mobile%22&Toal==%22%2B1234567%22
See my working example here: https://stackoverflow.firebaseio.com/65924783.json?orderBy=%22mobile%22&equalTo=%22%2B1234567%22
这篇关于Firebase Realtime equalTo不能与"+123"之类的String一起使用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!