如何通过firebase中的嵌套值获取键名?

Pra*_*tha 3 objective-c livechat ios firebase firebasesimplelogin

在此输入图像描述

我的firebase以这种方式建模.我想写一个查询来获取userID(simplelogin:1),其中email是"test@gmail.com".

在这里,我想获得密钥:"simplelogin:1"通过搜索它的电子邮件地址:"test@gmail.com"

我正在使用firebase SDK for iOS.有人可以建议我查询吗?在Javascript或Objective-C中

Pra*_*tha 9

在一点点搞乱之后,我找到了问题的答案:

Firebase *ref = [_rootReference childByAppendingPath:@"Users"];

[[[ref queryOrderedByChild:@"Email"]queryEqualToValue:@"test@gmail.com" ]
 observeEventType:FEventTypeChildAdded withBlock:^(FDataSnapshot *snapshot) {
     NSLog(@"%@ Key %@ Value", snapshot.key,snapshot.value);
 }];
Run Code Online (Sandbox Code Playgroud)

snaphot.key将是我想要的值simplelogin:1.