stingerlabs / ember-graph

Ember persistence library for complex object graphs
http://stingerlabs.github.io/ember-graph/
MIT License
76 stars 5 forks source link

Relationship partial loading #47

Open gordonkristan opened 10 years ago

gordonkristan commented 10 years ago

Add the ability for the store to accept partial records, merging them with old records. The number one use case for this is pagination. When 50 IDs are loaded, to load the next 50, there's no reason to re-load the old 50.

gordonkristan commented 10 years ago

This should work for attributes as well as relationships. This way record updates don't have to return the full record.

gordonkristan commented 10 years ago

I really hate the RFC6902 PATCH format, so I'm not going to use it in the normalized payload format. However, I do think we can do something similar (vs a Mongo like syntax).

{
    "id": "1",
    "type": "user",
    "op": "add",
    "type": "relationship",
    "property": "posts",
    "value": {
        "id": "10",
        "type": "post"
    }
}

These would possibly reside in a changes object. I'm thinking the format might move to something like this:

{
    "meta": {},
    "records": {},
    "changes": {
        "user": {
            "1": [
                {}, {}, {}
            ]
        }
    }
}

This would keep the changes grouped for easy loading.