pichfl / ember-data-primus

Ember Data adapter using Primus as transport layer supporting various WebSocket implementations.
MIT License
1 stars 0 forks source link

Partial updates and deletes #2

Open noxan opened 8 years ago

noxan commented 8 years ago

How to handle deletion of records with partial updates?

Does JSONAPI cover deletion updates from server side in any way? At least I did not find any notes on this subject so far.

pichfl commented 8 years ago

Since JSONAPI is tailored to HTTP, this is not yet in the spec as far as I know.

We could however use the same calls a client uses to delete document on the server, it's rather similar after all.

So we broadcast something like "DELETE /resource/1" to all connected clients if such a call is received.

pichfl commented 8 years ago

A few ideas:

We switch to primus-emit, which is a module maintained by primus. We emit multiple events and use them to implement a small set of methods.

Clients have to decide on how to handle conflicts.

method description
PUSH Send data to the client.
DELETE Remove one or multiple entries from the client.

DELETE

Send either an array or a single object, which should be formatted like a relationship entry in JSONAPI.

DELETE {
    "data": {"id": "42", "type": "people"}
}

DELETE [
    {
        "data": {"id": "42", "type": "people"}
    },
    {
        "data": {"id": "12", "type": "people"}
    }
]