-
Notifications
You must be signed in to change notification settings - Fork 3
Database
We use the Firebase platform for all the backend hosting needs of the VC DECA app. You can access the Firebase Project here. For more information on the actual backend code running on the server, check out the Backend page.
Storing user and event data is all handled through the Firebase Real-Time Database. Data is split up into various branches based on where the information is going to be requested from.
Currently, there are 5 top level branches from the Database. In addition to these branches, there are also a number of static fields to extract general information from the user-end. All of these are defined in more detail below.
This branch of the database is used for storing announcement information that is posted to the database from the user. The reason that the branch is titled alerts
even though it should be called announcements
is because I am a horrible speller, so I wanted to reduce the possibility of an app crash for misspelling the branch name every time I needed to extract data from there.
Alerts are stored in the following JSON structure:
{
"title": "Announcement Title",
"body": "Announcement body example",
"date": "mm/DD/yyyy HH:mm"
}
The date
field is automatically generated by the user-end device where HH:mm
is in the 24-hour time format. The whole thing is then wrapped in another JSON before being uploaded to the Database directly under the alerts
branch.
{
"-LOJEg05sh4Pr7a_1Pat": {
"title": "Announcement Title",
"body": "Announcement body example",
"date": "mm/DD/yyyy HH:mm"
}
}
The key in this JSON is automatically generated via the Firebase childByAutoId
function which generates a new unique key. This unique key is based on a timestamp, so list items will automatically be ordered chronologically. Because Firebase generates a unique key for each blog post, no write conflicts will occur if multiple users add an announcement at the same time.
vc-deca
|-- alerts
|-- -LOJEg05sh4Pr7a_1Pat
|-- title: "Meeting Reminder"
|-- date: "08/10/2018 09:18"
|-- body: "Hey guys, this is just a reminder about our meeting today!"
The chat system on the app