Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store.push support plural and singular types #6457

Closed
esbanarango opened this issue Sep 16, 2019 · 2 comments
Closed

Store.push support plural and singular types #6457

esbanarango opened this issue Sep 16, 2019 · 2 comments

Comments

@esbanarango
Copy link
Contributor

Is there a reason behind store.push only supporting singular types?

Store_-_3_12_-_Ember_API_Documentation

@runspired
Copy link
Contributor

We've been discussing potentially having push normalize the type to ensure it is singular. Roughly the current thinking is that by the time payloads enter the store (via store.push) they are supposed to have already been normalized. This includes making type singular and dasherized.

Why singular and dasherized?

A few reasons:

  • They are dasherized because the type should match the file-name the Model is defined in, and file-names are typically dasherized.

  • They are singular by convention partly since records tend to be worked with one at a time in the singular (think of the dissonance of store.createRecord('users', {}), and partly because file names are also typically singular for a file/module representing one thing (a User class for instance) and plural for a file/module representing a collection of things.

This constraint is one we tend to lift. Most places in the internals we no longer normalize type, we accept whatever you gave us. While this can lead to mistakes (e.g. in one place you normalize to users and in another user), we are working towards a world in which the convention on type is entirely left to the consuming application.

@runspired
Copy link
Contributor

Closing because we don't want to add more normalization and we are currently working to deprecate what normalization we already do via RFCs emberjs/rfcs#739 and emberjs/rfcs#740

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants