ember-data-model-fragments icon indicating copy to clipboard operation
ember-data-model-fragments copied to clipboard

empty fragment array not sent to server

Open aandis opened this issue 6 years ago • 3 comments

Given


// app/models/person.js
export default Model.extend({
  name: attr('string'),
  addresses : fragmentArray('address'),
});

// app/models/address.js
export default Fragment.extend({
  street  : attr('string'),
  country : attr('string')
});

If person looks like -

{
  "name": "John",
  "addresses": [
    { "street": "test", "country": "test" }
  ]
}

and I delete the address object from person in my app with

this.get('model').get('addresses').removeAt(0)

and try to save the model, the json posted is -

{ "name": "John" }

I would expect the following json to be posted -

{ "name": "John", "addresses": [] }

Is this expected behavior?

aandis avatar Dec 28 '18 17:12 aandis

ping.

aandis avatar Jan 07 '19 04:01 aandis

hello @aandis I don't think the behavior has been explicitly defined but I would accept a PR to fix it.

jakesjews avatar Jan 08 '19 22:01 jakesjews