Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone-relations

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-relations - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

30

backbone-relations.js

@@ -21,3 +21,3 @@ (function () {

get: function (attr) {
var rel = this.relations[attr];
var rel = this.relations && this.relations[attr];
if (!rel) return get.call(this, attr);

@@ -58,15 +58,17 @@ var instance = rel.instance;

}
for (key in attrs) {
var rel = this.relations[key];
if (!rel) continue;
val = attrs[key];
delete attrs[key];
if (rel.hasOne) {
var instance = this.get(key);
var model = val instanceof rel.hasOne ? val.attributes : val;
instance.set(model, options);
if (this.get(rel.fk) !== instance.id) attrs[rel.fk] = instance.id;
} else {
var models = val instanceof rel.hasMany ? val.models : val;
this.get(key).update(models, options);
if (this.relations) {
for (key in attrs) {
var rel = this.relations[key];
if (!rel) continue;
val = attrs[key];
delete attrs[key];
if (rel.hasOne) {
var instance = this.get(key);
var model = val instanceof rel.hasOne ? val.attributes : val;
instance.set(model, options);
if (this.get(rel.fk) !== instance.id) attrs[rel.fk] = instance.id;
} else {
var models = val instanceof rel.hasMany ? val.models : val;
this.get(key).update(models, options);
}
}

@@ -73,0 +75,0 @@ }

{
"name": "backbone-relations",
"version": "0.1.4",
"version": "0.1.5",
"author": "Casey Foster <c@sey.me>",

@@ -5,0 +5,0 @@ "licence": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc