値が何か等しいfirebaseからswift3でデータを取得するにはどうすればよいですか?iOS Firebaseは値が何かに等しいデータを取得します
"SELECT * FROM users WHERE type = 'brown'";
の場合、where
をFirebaseに書き込むにはどうすればよいですか?
私はこのDB
を持っていると私は、私の知る限り承知しているとして、それmonth
== currentMonth
(私はcurrentMonth
変数を持っている)
値が何か等しいfirebaseからswift3でデータを取得するにはどうすればよいですか?iOS Firebaseは値が何かに等しいデータを取得します
"SELECT * FROM users WHERE type = 'brown'";
の場合、where
をFirebaseに書き込むにはどうすればよいですか?
私はこのDB
を持っていると私は、私の知る限り承知しているとして、それmonth
== currentMonth
(私はcurrentMonth
変数を持っている)
からすべてのデータを取得したいですfirebase realtimeデータベースは、このようなクエリをサポートしていません。代わりに、全体のref 'budget'を呼び出してから、アプリ内でローカルにフィルタリングする必要があります。
FireStoreはベータ版ではあるが、明らかにクエリサポートが優れています。このような
することはできQuery
:
let ref = Database.database().reference()
ref.child("Budget")
.queryOrdered(byChild: "Month")
.queryEqual(toValue: "November")
.observe(.value, with: { (snapshot: DataSnapshot) in
var array:[Budget] = []
for budgetChild in snapshot.children {
let budgetSnapshot = budgetChild as! DataSnapshot
let budgetDictionary = budgetSnapshot.value as! [String:String]
let budget: Budget = Budget()
budget.description_ = budgetDictionary["Description"]
budget.month = budgetDictionary["Month"]
budget.type = budgetDictionary["Type"]
budget.value = budgetDictionary["Value"]
array.append(budget)
}
})