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

[QUESTION] [3.0.0-beta.1] Is the fragmentArray ordering important when saving and updating? #359

Open
dmuneras opened this issue Mar 3, 2020 · 0 comments

Comments

@dmuneras
Copy link

dmuneras commented Mar 3, 2020

Hi,

Context

I don't have much experience using fragments.

  • I have a fragmentArray and I am manipulating the objects, adding and removing them.
  • These are the version of the related addons:
    "ember-data": "3.1.2",
    "ember-data-model-fragments": "3.0.0-beta.1",

Note: As always, willing to upgrade

  • The array is created in the normalizeResponse serializer of the owner.

Problem

In a template I iterate the objects of the fragment, I manipulate the fragments using: removeFragment and addFragment to add and remove (which seems to be simple wrappers for addObjects and removeObjects).

I am even calling destroy in the removed objects using .destroy() after removing it from the fragment. But, even when doing that, the fragment array gets mess up after saving the parent model, even though the response is correct when it gets to the parent serializer and seems to be correct until the point when Ember data push it into the store.

Work around that seems to work

If I sort the array by a unique object key when adding new objects and when I get it them serializer, everything seems to work ok. It seems like somehow, the array ordering is important to keep consistency when manipulated fragments inside the fragment array.

Questions

  • Is the ordering of a fragmentArray ordering to keep consistency?
  • How do I remove fragments completely from the store?

Best regards,
Daniel.

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