Skip to content

[EMBER DATA] record links & meta#332

Merged
runspired merged 1 commit intoemberjs:masterfrom
runspired:ember-data-record-links-and-meta
Oct 19, 2018
Merged

[EMBER DATA] record links & meta#332
runspired merged 1 commit intoemberjs:masterfrom
runspired:ember-data-record-links-and-meta

Conversation

@runspired
Copy link
Contributor

@runspired runspired commented May 11, 2018

@jgwhite
Copy link

jgwhite commented May 11, 2018

Great proposal, would be a very welcome addition to ED.

Couple of nice-to-haves:

  • Examples of what one might use meta and links for
  • A code snippet demonstrating how one would rename links/meta in the serializer

Do you think links/meta would also be processed by the serializer to normalize keys?

@runspired runspired added the T-ember-data RFCs that impact the ember-data library label Jun 27, 2018
@sandstrom
Copy link
Contributor

@runspired This would be very useful! 👍

@runspired
Copy link
Contributor Author

@jgwhite

Examples of what one might use meta and links for

meta is very much a grab-bag, but many folks use it to store permissions, expirations, or other information about the resource's data that isn't part of the data itself.

links in the json-api sense are used to fetch and manipulate a resource. Adapters could be made to prefer links when present instead of using buildUrl.

A code snippet demonstrating how one would rename links/meta in the serializer

normalize(modelClass, resource) {
    let { attributes } = resource;
    attributes.attributeMeta = attributes.meta;
    delete attributes.meta;

    attributes.resourceLinks = attributes.links;
    delete attributes.links;

    return this._super(modelClass, resource);
  }

Do you think links/meta would also be processed by the serializer to normalize keys?

Serializers are user-land API space and implementations vary too widely for us to generalize. What is important is that for you to make use of meta and links in this way that you transform them into the correct position as specified by the json-api spec (sibling members to type id attributes and relationships).

There will be no changes to the serializers, so any key munging rules your serializers use would also apply

@runspired
Copy link
Contributor Author

As there have been no further comments, merging.

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

Labels

Final Comment Period T-ember-data RFCs that impact the ember-data library

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants