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

Add attribute level save/update control #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ahacking
Copy link
Contributor

This PR add the ability to control what attributes or relationships are sent back to the server as sometimes is it is undesirable to send everything back, e.g. read-only attributes or other meta data managed by the server or relationships which should not be managed through the model.

On your model you can now do:

var Person = Model.extend({
   createdAt: Ember.attr(Date, {update: false}),
   searchHits: Ember.attr(Number, {save: false}),
   friendships: Ember.hasMany('App.Friendship', {save: false})
});

The save: false option prevents the attribute ever being sent on a create or update, whilst the update: false option will never update the attribute, but does allow the value to be sent on a create. This control is intended to be independent/orthogonal of any adapter implementation since it controls the toJSON() serialisation of the model which occurs prior to the data being given to the adapter for persistence.

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

Successfully merging this pull request may close these issues.

2 participants