Last active
October 2, 2017 17:15
-
-
Save oogatta/de4f841c6195be5efaa914b4c50bd1d4 to your computer and use it in GitHub Desktop.
This file contains 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") | |
.once("value", snapshot => { | |
Object.values(snapshot.val()).forEach(value => { | |
console.log(`(${value.hoge}, ${value.fuga})`); | |
}); | |
}); | |
// 🍎 iOS Swift | |
Database.database().reference().child("test").child("iOS") | |
.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") | |
.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