How would I do this:
Lets say I have a db that stores appointments:
Start time, person name,AppointmentUID
I do an api call and I get a list of 10 appointments with the properties mentioned above.
HOW:
Now that the api has received the 10 appointments I need to:
-loop through them and check:
---- Does the appointment already exists?
--------It does not exist in current db = save it to db
--------it does exist in current db = check the details are the same, if they are not then UPDATE the fields that have changed.
===========================================
Visual example:
Let’s say on 1/1/2023 I have the following appointments in my db:
(name, appointment UID, start time)
-Sam, 00001, 1:00
-Jack, 00002, 2:00
-Tom, 00003, 3:00
-Kim, 00004, 4:00
Now I call api on that same day to get all appointments, the API returns:
-Sam, 00001, 1:00
-Jack, 00002, 2:20
-Tom, 00003, 3:00
-Kim, 00004, 4:00
-Zack, 00005, 6:00
As you see we have no change on:
Sam
Tom
Kim.
We have a chance on:
Jack
We have a new record:
Zack
Need to not update Sam, Tom, Kim
Need to update Jack’s start time
Need to add Zacks appointment to db
Help