Getting dictionary of all data in a database reference #147
-
Hello! Having trouble with this as the chat example seems to be listening for new data rather than retrieving all data. I Have successfully pushed data to the database. I assumed I would use get_data on the same database reference to get a dictionary of the data but I get an error "Invalid get index '_root' (on base: 'Dictionary')." What am I doing wrong or what could be wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Can't say with certainty, but my immediate thought is that you haven't actually waited for it to pull data back. You should only be calling things after the reference has completed initializing. More importantly, the example you're looking at is for the part of the chat app which pushes the data, not the one which listens for it. (It will listen for it, but in this case it is ignored.) What you're looking for regarding what to do is: https://github.com/GodotNuts/FirebaseDemo-Chat/blob/main/Chat.gd#L15 - No need to do a get_data if you're reading the data in the new_data_update signal which returns you the data. This one will return the entire set of data at the very beginning for you as well, but from that point onward, only updates. |
Beta Was this translation helpful? Give feedback.
Can't say with certainty, but my immediate thought is that you haven't actually waited for it to pull data back. You should only be calling things after the reference has completed initializing. More importantly, the example you're looking at is for the part of the chat app which pushes the data, not the one which listens for it. (It will listen for it, but in this case it is ignored.) What you're looking for regarding what to do is: https://github.com/GodotNuts/FirebaseDemo-Chat/blob/main/Chat.gd#L15 - No need to do a get_data if you're reading the data in the new_data_update signal which returns you the data. This one will return the entire set of data at the very beginning for you as w…