jeffminsungkim / Ashy

0 stars 0 forks source link

Friends node synchronization based upon users data #8

Closed jeffminsungkim closed 6 years ago

jeffminsungkim commented 6 years ago

Objective Synchronize friend list of every user.

I should update friends node values simultaneously every time the related data get changed from elsewhere.

Each child node consists of a user array that has a user id as a key of friends node. The reason why I store as an array is because each user could have many friends. In this example, Jeff Kim has one friend which is John Doe vice versa.

- friends
    - VkwT5IgS7ZYqDZ4uz5Dh76inrAK2
       - displayName: Jeff Kim
       - photoURL: https://firebase...
       - currentActiveStatus: Online
       - statusMessage: ...
    - 5NnRVze6TVUeunLV0KXVmLby03J2
       - displayName: John Doe
       - photoURL: https://firebase...
       - currentActiveStatus: Offline
       - statusMessage: ...

When users node gets changed, the related data in friends node must be updated. For example, when Jeff Kim has changed his profile photo or statusMessage, all the same, user id that reside in friends node which matches with Jeff Kim’s uid, data should be updated based upon what user has changed.

- users
    - VkwT5IgS7ZYqDZ4uz5Dh76inrAK2
       - displayName: Jeff Kim
       - photoURL: https://firebase...
       - currentActiveStatus: Online
       - statusMessage: ...
    - 5NnRVze6TVUeunLV0KXVmLby03J2
       - displayName: John Doe
       - photoURL: https://firebase...
       - currentActiveStatus: Offline
       - statusMessage: ...
jeffminsungkim commented 6 years ago

The data structure has changed. Thus, data denormalization is unnecessary.