sidferreira / aor-firebase-client

Firebase client for Admin on Rest
MIT License
57 stars 29 forks source link

Overwrites externally modified data #27

Open jjjjjjjjjjjjjjjjjjjj opened 7 years ago

jjjjjjjjjjjjjjjjjjjj commented 7 years ago

Right now we seem to be sending the entire record to Firebase's update function, instead of just the properties that have been updated in AOR. This could cause problems. To illustrate:

  1. I open up user foo in AOR.
  2. User foo joins a group bar in My app.
  3. My app creates a relation users/foo/groups/bar in Firebase DB.
  4. I edit user foo's name to "John Doe" in AOR.
  5. I hit save in AOR.
  6. users/foo/groups/bar will be deleted from Firebase DB by AOR.
  7. users/foo/name will be set to "John Doe" in Firebase DB by AOR.
  8. User foo is no longer a member of group bar in my app.

Could it be solved by a comparison of params.previousData vs params.data before posting to firebase, then posting only the fields that have been changed?

sidferreira commented 7 years ago

@janneklouman Good point! I have some big changes to upload now, it will be great if you can help me on this part :)

sidferreira commented 7 years ago

@janneklouman There's an UPLOAD branch with the new codes. Feel free to make the changes there. It is a new version of the plugin including upload and other details

sidferreira commented 6 years ago

@janneklouman Reviewing this... It makes sense, but the problem is how deep can we handle that? The proper solution is a deepMerge, indeed, but need to plan how to integrate it