我试图查询Firebase数据库中的食物清单。该应用程序有一个UITextfield,用户可以在其中键入食物项目的搜索词。我已经使用以下代码实现了基本代码。
NSString *searchString = [sender.text lowercaseString];
[[[[[self.ref queryOrderedByChild:@"fuudTitleCapped"] queryLimitedToLast:5] queryStartingAtValue:searchString] queryEndingAtValue:[NSString stringWithFormat:@"%@\uf8ff",searchString]] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
NSLog(@"%@ Key %@ Value", snapshot.key,snapshot.value);
}];
我的数据库结构如下
{
"fuuds": {
"-KMT1MHSrR-n6TN9K_wR": {
"fuudDescription": "Dummy discrp",
"fuudImage": "Dummy image",
"fuudLatitude": "Dummy lat",
"fuudPrice": 154,
"fuudRating": "54",
"fuudRestaurent": "Dummy rest",
"fuudTitle": "Dummy title",
"fuudTitleCapped": "Dummy title"
},
"-KMT1MHVAo0OxMkKBktB": {
"fuudDescription": "Dummy discrip",
"fuudImage": "Dummy image",
"fuudLatitude": "Dummy lat",
"fuudPrice": 46,
"fuudRating": "7854",
"fuudRestaurent": "Dummy rest",
"fuudTitle": "Dummy title",
"fuudTitleCapped": "Dummy title"
}
}
}
我想要的是通过密钥" fuudPrice"来订购结果。
有人可以建议我这样做吗?