I posted this question in the data section but have not received any feedback. Please advise me on the below question:
I have a system that poles a data source and stores the results in a table. Both the original source and the storage destination have the save database design, one parent and several children in a one-to-many design. I need to design a way to compare the new data set (that comes from the poled data source) with the old data set (which comes from the stored database) and update the stored data set with the most up to date records. Each record has a time stamp for when it was created and last updated. so, this system needs to take the following rules into consideration:
1. compare each parent record, if the data from data set 1 = the data from data set 2 do nothing (its already updated).
2. if the data from data set 1 is more recent then data set 2 update data set 2.
3. if the data from data set 1 is older then data set 2, do nothing (its already updated)
4. if the data from data set 1 was deleted but still exists in data set 2, remove it.
Then, this same process needs to occur for all the children records. Essentially, i just need to know how to syncronize to data sets. If I weren't using GORM i would just iterate through each record set using SQL. How can i do this using GORM? Doing the parent isnt difficult the problem i've been having is with the children.