I am trying to create a child using the Firebase data view but it seems that this is not possible as the create node directly disappears or rather doesn't show up at any time. I tried to leave the value field empty but this doesn't work at all as well as writing null into the value field. Am I doing it wrong?
-Fabian
By default, a query retrieves all documents that satisfy the query in ascending order by document ID. You can specify the sort order for your data using orderBy() , and you can limit the number of documents retrieved using limit() .
You can use hasChildren() to determine if a DataSnapshot has any children. If it does, you can enumerate them using forEach() . If it doesn't, then either this snapshot contains a primitive value (which can be retrieved with val() ) or it is empty (in which case, val() will return null ).
If you open your app from Firebase dashboard, you can add data manually by clicking on the + sign. We will create a simple data structure.
Null and empty values are the same as the record not existing. If you want it to exist, you have to set a value.
In other words, when you test for a record's existence, you aren't looking to see if the key is in the database, you are looking to see if the path (the location of that key) has any data.
Suggestion: use a falsy value like 0 or false until you have some data to throw into that location. You're not limited by data types as you would be with SQL, so you can always replace that with an object/array/et al later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With