There is no way to add an element to an array in the Firebase Realtime Database without first reading the entire array. So you'll have to:
Read the current elements in the array
Add the item to the array
Write the entire array back to the database
This is one of the (many) reasons why Firebase recommends against using arrays for list-like structures and prefers using lists or maps. I recommend checking out Best Practices: Arrays in Firebase.
发布评论
评论(1)
如果不读取整个数组,则无法在Firebase实时数据库中的数组中添加元素。因此,您必须:
将 使用列表或地图。我建议您查看最佳实践:firebase 。
There is no way to add an element to an array in the Firebase Realtime Database without first reading the entire array. So you'll have to:
This is one of the (many) reasons why Firebase recommends against using arrays for list-like structures and prefers using lists or maps. I recommend checking out Best Practices: Arrays in Firebase.