Skip to content

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

Description

@dmuneras

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions