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 | |
// JS だけ value ではソートが効かないのはバグか仕様か | |
admin.database().ref().child("test").child("Admin") | |
.orderByChild("fuga") // ソートキー | |
.on("child_added", snapshot => { | |
console.log(`(${snapshot.val().hoge}, ${snapshot.val().fuga})`); | |
}); | |
// 🍎 iOS Swift |
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") | |
.orderByKey() // キーでソート | |
.limitToLast(3) // 切り取る範囲 | |
.once("value", snapshot => { | |
Object.values(snapshot.val()).forEach(value => { | |
console.log(`(${value.hoge}, ${value.fuga})`); | |
}); | |
}); | |
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") | |
.orderByKey() // キーでソート | |
.limitToFirst(3) // 切り取る範囲 | |
.once("value", snapshot => { | |
Object.values(snapshot.val()).forEach(value => { | |
console.log(`(${value.hoge}, ${value.fuga})`); | |
}); | |
}); | |
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") | |
.orderByKey() // キーでソート | |
.once("value", snapshot => { | |
Object.values(snapshot.val()).forEach(value => { | |
console.log(`(${value.hoge}, ${value.fuga})`); | |
}); | |
}); | |
// 🍎 iOS Swift |
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") |
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
FirebaseDatabase.getInstance().reference.child("test").child("Android").apply { | |
setValue(null) | |
push().setValue(mapOf("hoge" to 1, "fuga" to 5)) | |
push().setValue(mapOf("hoge" to 2, "fuga" to 4)) | |
push().setValue(mapOf("hoge" to 3, "fuga" to 3)) | |
push().setValue(mapOf("hoge" to 4, "fuga" to 2)) | |
push().setValue(mapOf("hoge" to 5, "fuga" to 1)) | |
} |
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
let targetReference = Database.database().reference().child("test").child("iOS") | |
targetReference.setValue(nil) | |
targetReference.childByAutoId().setValue(["hoge": 1, "fuga": 5]) | |
targetReference.childByAutoId().setValue(["hoge": 2, "fuga": 4]) | |
targetReference.childByAutoId().setValue(["hoge": 3, "fuga": 3]) | |
targetReference.childByAutoId().setValue(["hoge": 4, "fuga": 2]) | |
targetReference.childByAutoId().setValue(["hoge": 5, "fuga": 1]) |
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
with (admin.database().ref().child("test").child("Admin")) { | |
set(null); | |
push().set({"hoge": 1, "fuga": 5}); | |
push().set({"hoge": 2, "fuga": 4}); | |
push().set({"hoge": 3, "fuga": 3}); | |
push().set({"hoge": 4, "fuga": 2}); | |
push().set({"hoge": 5, "fuga": 1}); | |
} |
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
class MainActivity : AppCompatActivity() { | |
val controller = MySweetController() | |
var vmList = arrayListOf<MySweetViewModelable>() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
vmList.add(TitleViewModel("Hello, Ebisu!")) | |
// ... | |
my_sweet_recycler_view.adapter = controller.adapter | |
updateController() |
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
class MainActivity : AppCompatActivity() { | |
lateinit var adapter: RecyclerView.Adapter<RecyclerView.ViewHolder> | |
var vmList = arrayListOf<MySweetViewModelable>() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
// Title | |
vmList.add(TitleViewModel("Hello, Ebisu!")) | |
// ... | |
adapter = MySweetAdapter(vmList) | |
my_sweet_recycler_view.adapter = adapter | |
} |