我试图了解如何在Firebase数据库中进行搜索以检查记录是否存在,以及是否存在以在该特定分支下获取详细信息。
目前,我可以通过捕获特定记录并将其放入文本字段然后从那里开始来完成我需要做的事情,但是我需要对数据库中的多个记录进行检查,直到找到特定记录为止,然后从那里加载所有详细信息在那个分支下。
这是我目前正在做的事情;
Firebase *ref = [[Firebase alloc] initWithUrl: @"https://sizzling-inferno-255.firebaseio.com/"];
//Refer to users entity
Firebase *usersRef = [ref childByAppendingPath: @"id/"];
// Read data and react to changes
[usersRef observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
NSLog(@"%@ -> %@", snapshot.key, snapshot.value);
NSDictionary *dict=[NSDictionary dictionaryWithDictionary:snapshot.value];
NSString *stri=[NSString stringWithFormat:@"%@",dict];
_textview1.text = stri;
string1 = snapshot.key;
_label1.text = string1;
}];
随时使用URL检查自己,无论如何我仅将其用于测试。
我是Firebase的新手,但是在新版本上我做得太多了。
是Record
您key
内心的名字sizzling-inferno-255
吗?如果是这样。在这个新版本中,您可以通过以下方式检索一些信息:
FIRDatabaseReference *usersRef = [[FIRDatabase database] reference];
[[[[usersRef child:@"results"] child:@"sizzleing-inferno-255"] child:@"record"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
NSString *record = snapshot.value;
if(record.length > 0) {
// Yes! there is a record.
}
}
那是你要的吗?让我知道。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句