RESTAdapter learned side-deleting. #379

Closed
wants to merge 1 commit into
from

6 participants

@hjdivad
Ember.js member

If the adapter has a deleteMapping property, records can be side deleted as
well as sideloaded when responses set this property to a hash of type names
to list of ids. For example:

  store.adapter.deleteMapping = '_deleted';

  // POST /people
 {
   person: { id: 1, name: "David" },
   groups: [{ id: 1, name: "Coffee Addicts" }],  //sideloading
   _deleted: {                                   // side deleting
     groups: [ 3, 4, 5 ],
     people: [ 6 ]
   }
 }
@wagenet
Ember.js member

So the use case for this is for the server to notify you when records have been deleted there that you may not have known about locally?

@hjdivad
Ember.js member

@wagenet That is exactly right.

@michaelbaudino

This seems bloody useful for data consistency between the app and the data persistence layer !

@hjdivad hjdivad RESTAdapter learned side-deleting.
If the adapter has a deleteMapping property, records can be side deleted as well
as sideloaded when responses set this property to a hash of type names to list
of ids.  For example:

  store.adapter.deleteMapping = '_deleted';

  // POST /people
  {
    person: { id: 1, name: "David" },
    groups: [{ id: 1, name: "Coffee Addicts" }],  //sideloading
    _deleted: {                                   // side deleting
      groups: [ 3, 4, 5 ],
      people: [ 6 ]
    }
  }
a961815
@hjdivad
Ember.js member

The test failures for f357af8 were unrelated to this patch. I've rebased against master, which is now building.

@hjdivad
Ember.js member

@wagenet @wycats @tomdale What can I do to move this PR forward? Are there concerns about the feature or the implementation in this PR?

@darthdeus
Ember.js member

This seems too good to be true.

@tomdale
Ember.js member

Are there any servers in the wild with which this patch will work?

@hjdivad
Ember.js member

@tomdale there is at least one.

I think there are two decisions to make

  1. Should ember-data have this feature?
  2. If yes, what should be the API

Personally I think it's important to have this feature: servers could potentially make many changes, including deletes, and it makes sense for the RESTAdapter to support this out of the box.

As for the API I think there are two reasonable ones: this one (a specially designated key) or use the payload meta feature that @tchak added.

Thoughts?

@tchak
Ember.js member

@tomdale @wycats can we have a new discussion on this in the light of jsonapi?

@tchak tchak referenced this pull request in json-api/json-api May 5, 2013
Closed

Define a semantics for "side-deleting" #18

@tomdale
Ember.js member

Let's move this discussion to JSON API. Whatever they decide, we will implement.

@tomdale tomdale closed this May 10, 2013
@heartsentwined heartsentwined referenced this pull request May 16, 2013
Closed

json-api conformity #983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment