Skip to content

Unable to remove a key from User Prefs #316

Closed

Description

@Heartless49

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.

Activity

  1. self-assigned this
    on May 1, 2020
  2. added
    bug
    on May 1, 2020
  3. eldadfux commented on May 18, 2020

    @eldadfux
    Member

    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?

  4. eldadfux commented on Aug 6, 2020

    @eldadfux
    Member

    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.

  5. added
    waiting for release
    on Aug 6, 2020
  6. eldadfux commented on Aug 9, 2020

    @eldadfux
    Member

    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.

  7. eldadfux commented on Feb 12, 2021

    @eldadfux
    Member

    This update is available on Appwrite 0.7

  8. removed
    waiting for release
    on Jun 22, 2021
  9. added 2 commits that reference this issue on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions