Database Core
Initialization
Before making any call to the Firebase Realtime Database, first, you should execute the Firebase Database Init function. If the result is a fail, study logs to find out what causes an issue.
https://gamednastudio.com/plugins/images/RealtimeDatabase/Wiki5.png
Permissions
The Realtime Database provides a declarative rules language that allows you to define how your data should be structured, how it should be indexed, and when your data can be read from and written to. By default, read and write access to your database is restricted so only authenticated users can read or write data. To get started without setting up Authentication, you can configure your rules for public access. This does make your database open to anyone, even people not using your game, so be sure to restrict your database again when you set up authentication. If you do not want to use public access you can add Firebase Authentication to your app to control access to the database.
Go Online/Offline
https://gamednastudio.com/plugins/images/RealtimeDatabase/Wiki6.png
You can manipulate whether your game is connected to the Firebase Realtime Database or not.
- Go Online – Resumes the connection to the Firebase Realtime Database backend after a previous Go Offline call.
- Go Offline – Shuts down the connection to the Firebase Realtime Database backend until Go Online is called.
Purge Outstanding Writes
https://gamednastudio.com/plugins/images/RealtimeDatabase/Wiki7.png
This function purges all pending writes to the Firebase Realtime Database server.
Database Reference
Database Reference represents a particular location in your Database and can be used for reading or writing data to that Database location. This class is the starting point for all Database operations. After you’ve initialized it with a URL, you can use it to read data, write data, and to create new Database Reference instances.
Get Reference
https://gamednastudio.com/plugins/images/RealtimeDatabase/Wiki8.png
You can get Database Reference using one of three available functions:
- Firebase Database Get Reference – get a Database Reference to the root of the database.
- Firebase Database Get Reference From Path – get a Database Reference for the specified path.
- Firebase Database Get Reference From URL – get a Database Reference for the provided URL, which must belong to the database URL this instance is already connected to.
Tree manipulating
https://gamednastudio.com/plugins/images/RealtimeDatabase/Wiki9.png
For more flexible tree manipulating you can use the following functions instead of paths or URLs:
- Child – gets a reference to a location relative to this one.
- Get Parent – gets the parent of this location, or get this location again if Is Root.
- Get Root – gets the root of the database.
- Is Root – returns true if this reference refers to the root of the database.
- Key – gets the string key of this database location.
- Url – gets the absolute URL of this reference.
The above example is an equivalent of path /users/eclarke and URL https://fir-gamedna.firebaseio.com/users/eclarke.