我试图了解如何在我的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检查自己,我只使用这个测试。
然而,我需要的不是目标C中的我发现了一些接近的东西。
发布于 2016-05-25 11:39:08
我是新的火车头,但我在新版本上做了太多的工作。
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.
}
}这是你想要的吗?让我知道。
https://stackoverflow.com/questions/37434317
复制相似问题