-
Hi everyone, I was wondering if anyone could point me in the right direction to store something into the Firebase Database - I have the config setup and originally expected the format to be similar to something like:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @Rysm , # Get a database reference, specifing the path. @some_filters can be an empty Dictionary {}
var database_reference : FirebaseDatabaseReference = Firebase.Database.get_database_reference("path/to/db/json", some_filters)
# Push a json to the database specified path, using a Dictionary
database_reference.push({'user_name':'username', 'message':'Hello world!'})
# Update a json to the database, knowing the resource name/path
database_reference.update(resource.key, {'message':new_data}) # @resource is a FirebaseResource returned from a signal
# Connect some signals to use Realtime features
database_reference.connect("new_data_update", self, "_on_new_data_update") # for new data
database_reference.connect("patch_data_update", self, "_on_patch_data_update") # for patch data
# Return new data
func _on_new_data_update(new_data : FirebaseResource):
print(new_data)
print(new_data.key, new_data.data)
# Return patched data
func _on_patch_data_update(patch_data : FirebaseResource):
print(patch_data)
print(patch_data.key, patch_data.data) |
Beta Was this translation helpful? Give feedback.
-
Following the above, this demo uses the Realtime Database a lot. Feel free to study it or use code from it directly. |
Beta Was this translation helpful? Give feedback.
-
Thank you all for your contributions and sharing. I also think it would be useful to have an example project in order to help make sense of the correct usage of this tool. |
Beta Was this translation helpful? Give feedback.
Hi @Rysm ,
We will add something more detailed in the wiki for sure in the future.
Here's some snippets on how to use Firebase Database.