Last active
October 2, 2017 17:14
-
-
Save oogatta/c1e2b9c9fe42d5918fd989b06a6067b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ☁️ Admin node | |
admin.database().ref().child("test").child("Admin") | |
.orderByKey() // キーでソート | |
.once("value", snapshot => { | |
Object.values(snapshot.val()).forEach(value => { | |
console.log(`(${value.hoge}, ${value.fuga})`); | |
}); | |
}); | |
// 🍎 iOS Swift | |
Database.database().reference().child("test").child("iOS") | |
.queryOrderedByKey() // キーでソート | |
.observe(.value, with: { snapshot in | |
snapshot.children.allObjects | |
.flatMap { ($0 as? DataSnapshot)?.value as? [String: Int] } | |
.forEach { print(($0["hoge"] ?? -1, $0["fuga"] ?? -1)) } | |
}) | |
// 🤖 Android Kotlin | |
FirebaseDatabase.getInstance().reference.child("test").child("Android") | |
.orderByKey() // キーでソート | |
.addListenerForSingleValueEvent(object : ValueEventListener { | |
override fun onCancelled(p0: DatabaseError?) {} | |
override fun onDataChange(snapshot: DataSnapshot?) { | |
snapshot?.children?.forEach { | |
println(it.getValue<Hoge>(Hoge::class.java)?.hoge to it.getValue<Hoge>(Hoge::class.java)?.fuga) | |
} | |
} | |
}) | |
// 🛎 結果はすべて | |
(1, 5) | |
(2, 4) | |
(3, 3) | |
(4, 2) | |
(5, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment