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

Clearing a to-many relationship in a "normal" patch #517

Closed
TristanKobalt opened this issue Feb 3, 2021 · 1 comment
Closed

Clearing a to-many relationship in a "normal" patch #517

TristanKobalt opened this issue Feb 3, 2021 · 1 comment
Assignees
Milestone

Comments

@TristanKobalt
Copy link

I am trying to update a value on a resource, and clear a to-many relationship at the same time like so:

api.update('my-resource', { id: 1, my-field: 'new value', my-to-many-relationship: [] });

However, the my-to-many-relationship is not being recognized as a relationship in this case. Am I doing something wrong? I would like this operation to remain atomical.

Thanks in advance!

@wopian
Copy link
Owner

wopian commented Feb 4, 2021

Should be fixed now in 10.0.0-alpha.10.

For 9.x and earlier, there is no possible fix as there is nothing to distinguish a null/[] attribute and a null/[] relationship.

Note that in 10.x (see Migration Guide#link-objects), relationships are now always objects with a data object/array.

api.update('my-resource', { 
  id: 1, 
  my_field: 'new value', 
  my_to_many_relationship: { data: [] },
  my_to_one_relationship: { data: null }
});

@wopian wopian added this to the 10 milestone Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants