You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Storing a JSON object for User Prefs works as expected, however upon trying to delete/remove a key from this object at a later time, the existing value persists.
Recreation/Tests (node-appwrite):
users.updatePrefs(userId, { "myKey": "Some value" }); // { "myKey": "Some value" }
users.updatePrefs(userId, { "myKey": "A new value" }); // { "myKey": "A new value" }
users.updatePrefs(userId, {}); // { "myKey": "A new value" }
users.updatePrefs(userId, { "myKey": undefined }); // 'Param "prefs" is not optional.'
users.updatePrefs(userId, { "myKey": null }); // { "myKey": null }
After the above tests, the only result that you can get to leaves a null value and the key still present in the User Prefs and no way to completely remove the key.
As brought up by @eldadfux, adding either a put method to update the prefs, or adding a delete method to remove a specific key may be possible solutions.
So I was thinking of changing this method from PATCH to PUT (as a breaking change) because I think it will be wired to have two methods in the SDK names updatePrefs / patchPrefs, putPrefs (?).
I don't particularly appreciate having this as a breaking change, but this is also exactly why we are still not in 1.0, to use feedback like this, and make sure the API is solid and consistent.
Bu using the PUT method, we can also avoid having another delete route, and this way, one route will be able to handle all operations. GraphQL is planned for 0.7/0.8 and will probably be a reasonable alternative to the current PATCH method.
Another update for previous comment: we finally decided to keep the use of PATCH methods, but now the prefs data is being updated and not merged. This is to create better consistency with other patch methods in the users and account services and to allow the deletion unwanted attributes.
Activity
eldadfux commentedon May 18, 2020
So I was thinking of changing this method from PATCH to PUT (as a breaking change) because I think it will be wired to have two methods in the SDK names updatePrefs / patchPrefs, putPrefs (?).
I don't particularly appreciate having this as a breaking change, but this is also exactly why we are still not in 1.0, to use feedback like this, and make sure the API is solid and consistent.
Bu using the PUT method, we can also avoid having another delete route, and this way, one route will be able to handle all operations. GraphQL is planned for 0.7/0.8 and will probably be a reasonable alternative to the current PATCH method.
@Heartless49 what do you think?
eldadfux commentedon Aug 6, 2020
A fix changing the update prefs method from patch to put has now been committed and will be released as a breaking change in Appwrite 0.7.
eldadfux commentedon Aug 9, 2020
Another update for previous comment: we finally decided to keep the use of PATCH methods, but now the prefs data is being updated and not merged. This is to create better consistency with other patch methods in the users and account services and to allow the deletion unwanted attributes.
eldadfux commentedon Feb 12, 2021
This update is available on Appwrite 0.7
Merge pull request appwrite#316 from utopia-php/codex/queue-prefetch
Merge pull request appwrite#316 from utopia-php/codex/queue-prefetch