Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SortKey becomes empty on update when using nested values in default function #602

Open
Jroon94 opened this issue Oct 12, 2023 · 1 comment

Comments

@Jroon94
Copy link

Jroon94 commented Oct 12, 2023

So, I have my secondary index's sort key set up as follows:

sk2: {
  hidden: true,
  onUpdate: true,
  default: ({ metadata: { firstName, lastName } }) => `${firstName}#${lastName}`,
},

When using Entity.put it populates the sk2 as expected,
However if I call Entity.update to update any attribute sk2 will become empty. This happens even if the metadata attribute is untouched.

If I move the firstName and lastName attributes out of the metadata map and assign them as individual attributes the sortkey is updated without issue. Is using nested attributes in default not supported? Or am I perhaps missing a step somewhere that makes this possible?

@Jroon94
Copy link
Author

Jroon94 commented Nov 13, 2023

Update: This only happens when using the $set operator. If I pass the entire metadata object into the update function, the default is triggered and updated accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant