
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
ember-data-updating-json-api-relationships
Advanced tools
Updating JSON:API relationships independently in Ember Data
This addon adds support to Ember Data to update relationships independently. See Updating Relationships in the JSON:API spec for more details. This library works for updating to-one and to-many relationships, as described in the JSON:API spec.
ember install ember-data-updating-json-api-relationships
First, extend the adapter:
// app/adapters/application.js
import DS from 'ember-data';
import JSONAPIAdapter from 'ember-data-updating-json-api-relationships/adapters/adapter';
export default JSONAPIAdapter.extend({
});
Second, extend the serializer:
// app/serializers/application.js
import DS from 'ember-data';
import JSONAPISerializer from 'ember-data-updating-json-api-relationships/serializers/serializer';
export default JSONAPISerializer.extend({
});
Third, add the model mixin to the model with the relationship that you want to update independently:
// app/models/article.js
import DS from 'ember-data';
import ModelMixin from 'ember-data-updating-json-api-relationships/mixins/model';
let { Model, attr, hasMany, belongsTo } = DS;
export default Model.extend(ModelMixin, {
title: attr('string'),
tags: hasMany(),
author: belongsTo()
});
Lastly, call updateRelationship(relationship) on your model:
article.get('tags').pushObject(tag1);
article.get('tags').pushObject(tag2);
// PATCH /articles/:id/relationships/tags
article.updateRelationship('tags');
article.set('author', author);
// PATCH /articles/:id/relationships/author
article.updateRelationship('author');
This addon will set relationship URLs to what is recommended in the spec, so something like /articles/:id/relationships/tags for a to-many relationship and /articles/:id/relationships/author for a to-one relationship. If you need to override this, use the urlForUpdateRelationship() hook:
// app/adapters/article.js
export default ApplicationAdapter.extend({
urlForUpdateRelationship(id, modelName, snapshot, relationshipToUpdate) {
let { host, namespace } = this;
if (relationshipToUpdate === 'tags') {
return `${host}/${namespace}/articles/${id}/categories`;
}
}
})
FAQs
Updating JSON:API relationships independently in Ember Data
We found that ember-data-updating-json-api-relationships demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.