检查 Firebase 中是否存在记录
Check if record exists in Firebase
我想了解如何在我的 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 自行检查,反正我只是用它来测试。
I found something close 到我需要的但是它不在 Objective C.
我是 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.
}
}
这是你想要的吗?让我知道。
我想了解如何在我的 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 自行检查,反正我只是用它来测试。
I found something close 到我需要的但是它不在 Objective C.
我是 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.
}
}
这是你想要的吗?让我知道。