stream-js icon indicating copy to clipboard operation
stream-js copied to clipboard

Update user seems to delete earlier user data

Open callmekatootie opened this issue 6 years ago • 2 comments

When we create a user, we pass certain attributes about the user (say username).

Now, when we update the user, the intention is to add more attributes (or update existing ones) of the user. However, it appears that when we update the user, we need to pass all the attributes, and not just the ones that are new / need updates. That is, we need to pass the username again, even though it has not changed.

I observed this when I fetched the feed along with enrichment and the data property of the actor attribute of an item in the feed only seemed to contain the attributes I had passed during update.

I am not sure if this is a bug or a feature. Seems like a bug to me, since during update, one would not send all attributes - only those that need updates. Perhaps you could have an option where we can overwrite all attributes with the ones passed during update (for when we need to delete certain attributes).

callmekatootie avatar Apr 12 '19 10:04 callmekatootie

Thanks for reporting this issue, I was also running into a similar issue and couldn't figure out why updates weren't working. I was able to get around this by fetching my existing user data and then performing an object spread to update existing fields or add new fields.

For example:

const user = await client.user(uid.get()
const updatedData = {
    ...user.data,
    ...myUpdatedData
  }
 client.user(uid).update(updatedData)

This definitely seems more like a bug than a feature, especially since the other API's support partial updates. Hopefully this will be resolved soon!

kelyvin avatar Aug 27 '19 02:08 kelyvin

What's the status on this? Is there a related issue we can follow, since this needs API support? Would be nice to get this fixed.

haggalin avatar Nov 26 '21 12:11 haggalin