我目前正在设置Firebase应用,并且能够检索使用该应用的所有用户的列表 . 当用户首次注册该应用时,他们需要确认他们的电话号码,因为这些天大多数iOS应用都会这样做 . 我将他们的电话号码存储在"users"节点中 . My question is how do I query in Firebase to check to see if that phone number exists within my database? Basically I want to query against a list of phone numbers that I'm generating against the list of all contacts
这将允许我显示特定联系人当前是否正在使用该应用程序,它将显示在tableview / collectionview中的联系人姓名下方 . 如果他们不是,那么他们可以通过短信/电子邮件收到加入应用程序的邀请 .
“用户”节点显示在我的Firebase数据库中,如下所示:
"users" : {
"userId1" : {
"name" : "Alex",
"email" : "alex@gmail.com",
"phoneNumber" : "123456789"
},
"userId2" : {
"name" : "Ben",
"email" : "ben@gmail.com",
"phoneNumber" : "223456789"
},
"userId3" : {
"name" : "Charles",
"email" : "charles@gmail.com",
"phoneNumber" : "323456789"
}
}
我是一个在nosql数据库中查询的新手,非常感谢你的帮助 . 非常感谢!
2 回答
首先,从firebase获取值并检查它是否存在 . 以下是示例代码
Another way: 直接跟踪路径并检查是否存在
尝试使用Firebase的排序功能 .
有关排序的更多信息,请访问:https://firebase.google.com/docs/database/ios/lists-of-data