ggneilc / stat-tracker

Health & Fitness Tracker designed to gamify life to increase motivation, written in react native
0 stars 0 forks source link

Understand and Correct Table Associations #1

Closed ggneilc closed 8 months ago

ggneilc commented 8 months ago

GORM has different one-to-one relationships, and we didn't know that at the time of writing the code lmfao. Need to look into it to make sure we are organizing things correctly for somewhat efficient queries and very scalable structure.

ggneilc commented 8 months ago

Table Associations for the most part are correct after a sneaky chatgpt question. The big thing was not how the table associations are done, but rather how the CRUD operations are handled because GORM uses something called 'Association Mode' to handle the data within the list. For example: you can't just directly access CurrentDay.Meals because Meals isn't loaded in yet -> its only referenced inside of Current day; you have to either preload the data or target the table directly with .Association