【发布时间】:2017-01-18 19:13:53
【问题描述】:
我在我的应用上设置了条码扫描器,当应用扫描了条码后,我希望它搜索我的 Firebase 数据库,看看它之前是否被扫描过。
这是我的 Firebase 数据库 JSON:
{
"Ingredients" : {
"Pork" : {
"Products" : {
"5741000124024" : {
"Amount" : "1",
"Unit" : "kg"
}
}
},
"apple" : {
"Products" : {
"5826374655024" : {
"Amount" : "200",
"Unit" : "g"
}
}
}
}
}
5741000124024 是我试图通过此代码查找的产品的条形码:
FIRDatabase.database().reference().child("Ingredients").queryEqual(toValue: code).observeSingleEvent(of: .value, with: { (snap) in
if !snap.exists() {
print("Not scanned before")
} else {
print("Found It")
}
})
它一直打印Not scanned before,即使条形码匹配,我在这里做错了什么?
【问题讨论】:
标签: ios json swift firebase firebase-realtime-database