Skip to content

Firestore Architecture

Benson Cho edited this page Mar 16, 2024 · 16 revisions

We use Firestore to manage the database infrastructure. Firestore index rules are currently not set up.

users collection

After a user signs up through the web app, extra information will be populated through this collection on top of the Firebase User object.

Field Type Example Value
date_of_birth timestamp 1 January 1970 at 00:00:00
does_freestyle boolean true
does_racing boolean false
does_snowboarding boolean false
does_ski boolean true
gender string female
emergency_name string Jane Doe
emergency_phone string 123 456 789
emergency_relation string Friend
first_name string John
last_name string Doe
membership string "admin" or "member""
dietary requirements string "no dairy"
faculty string or undefined Engineering
university 'UoA' or string or undefined 'Waikato'
student_id string or undefined 123456789
returning boolean true
university_year string "2nd" or "Graduate"

bookings collection

This manages the link between users and booking IDs

Field Type Example Value
user_id reference /users/lVsOjAp06AfD6atT8bnrVEpcdcg2
booking_slot_id reference /booking_slot/sddsdsdsds

Times of timestamps should be set to midnight.

booking_slot collection

The times that are available for the users to book

Field Type Example Value
product_id string stripe format
active boolean true
display_price number 50
name string
description string
start_date timestamp
end_date timestamp
max_bookings number 30
remaining_spots number 20

requests collection

This manages all requests by users to the executive team at UASC.

Field Type Example Value
user_id reference /users/lVsOjAp06AfD6atT8bnrVEpcdcg2
booking_id reference /bookings/8mYj7rWOMH6hGy4FzMed
query string Hello, when is your next event?
query_type string cancellation
status string unresolved
creation_time timestamp 1970-01-01T00:00:00Z
  • query_type allows for future different query types. Possible query types are
    • cancellation
    • dateChange
  • status indicates the status of the query for the executive team to see (can be unresolved or resolved)

Additional fields may be specified, depending on the query_type, as follows:

cancellation request

Has no additional fields specified.

dateChange request

The following additional fields are specified:

Field Type Example Value
old_check_in timestamp 25-07-2023
old_check_out timestamp 27-07-2023
new_check_in timestamp 26-07-2023
new_check_out timestamp 28-07-2023

Implementors should ensure that the range between old_check_out - old_check_in and new_check_out - new_check_in do not differ (i.e., the amount of days in the booking does not change).

Because Firebase does not have a timestamp without time, ensure that time is set to midnight.

booking_changes collection

This manages any changes that have happened to a specific booking.

This collection primarily exists to have a documented record of any changes applied to a booking.

Field Type Example Value
booking_id reference /bookings/8mYj7rWOMH6hGy4FzMed
old_check_in timestamp 26-07-2023
old_check_out timestamp 26-07-2023
new_check_in timestamp 27-07-2023
new_check_out timestamp 27-07-2023

Times of timestamps should be set to midnight.

Clone this wiki locally