Socket
Socket
Sign inDemoInstall

cascading-relations

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cascading-relations - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

16

index.js

@@ -5,3 +5,3 @@ var Q, dot, mongoose;

dot = require('dot-component');
dot = require('dotaccess');

@@ -31,4 +31,4 @@ Q = require('q');

orig = dot.get(this, path);
dot.set(this, path, val);
dot.set(this._related, path, orig);
dot.set(this, path, val, true);
dot.set(this._related, path, orig, true);
}

@@ -141,6 +141,6 @@ }

d.push(this._id);
dot.set(data, through, d);
dot.set(data, through, d, true);
}
} else {
dot.set(data, through, this._id);
dot.set(data, through, this._id, true);
}

@@ -280,8 +280,8 @@ }

}
dot.set(newRelated, path, newVal);
dot.set(newRelated, path, newVal, true);
} else {
if (rels._id === curVal) {
dot.set(newRelated, path, rels);
dot.set(newRelated, path, rels, true);
} else {
dot.set(newRelated, path, curVal);
dot.set(newRelated, path, curVal, true);
}

@@ -288,0 +288,0 @@ }

{
"name": "cascading-relations",
"version": "0.7.1",
"version": "0.7.2",
"description": "",

@@ -35,6 +35,6 @@ "main": "index.js",

"mongoose": "~3.8.3",
"dot-component": "~0.1.0",
"q": "~0.9.7",
"underscore": "~1.5.2"
"underscore": "~1.5.2",
"dotaccess": "~1.0.4"
}
}

@@ -1,2 +0,2 @@

var barClass, barSchema, bazClass, bazSchema, fooClass, fooSchema, mongoose, relations, should;
var barClass, barSchema, bazClass, bazSchema, dot, fooClass, fooSchema, mongoose, relations, should;

@@ -13,2 +13,4 @@ mongoose = require('mongoose');

dot = require('dot-component');
barSchema = new mongoose.Schema({

@@ -93,9 +95,11 @@ _foo: {

multi: {
_bars: [res._id]
_bars: [],
_bar: res._id
}
});
return foo.cascadeSave(function(err, res) {
return mongoose.model('Foo').find().populate('multi._bars').exec(function(err, res) {
res[0].multi._bars[0].toString().should.equal(bar._id.toString());
res[0]._related.multi._bars[0].title.should.equal('My Bar');
return mongoose.model('Foo').find().populate('multi._bar').populate('multi._bars').exec(function(err, res) {
console.log(res);
res[0].multi._bar.toString().should.equal(bar._id.toString());
res[0]._related.multi._bar.title.should.equal('My Bar');
return done();

@@ -257,6 +261,85 @@ });

});
return it('should apply filter to cascading relations when saving', function(done) {
it('should apply filter to cascading relations when saving', function(done) {
this.foo._related._bar.account.should.equal('asdf');
return done();
});
return it('should still work with deep dot notation', function() {
var obj;
obj = {
__t: "cornerstonesoftware__Unit",
__v: 2,
_id: "52cc929a90b078e563000024",
bathrooms: 1,
bedrooms: 1,
core_account: "main-account",
current_rent: 3000,
last_rent_increase: "Wed Jan 08 2014 15:49:46 GMT-0800 (PST)",
old_rent: 2000,
street: "777 Via Hierba",
unit_number: "1",
status: "rented",
rent_changes: [
{
rent: 1000,
effective_date: "Tue Jan 07 2014 15:49:46 GMT-0800 (PST)",
reason: "Unit added to system",
_id: "52cc929a90b078e563000025",
implemented: true,
id: "52cc929a90b078e563000025"
}, {
reason: "Rent changed on tenant details",
rent: 2000,
effective_date: "Tue Jan 07 2014 15:49:46 GMT-0800 (PST)",
_id: "52cc929a90b078e56300002f",
implemented: true,
id: "52cc929a90b078e56300002f"
}, {
effective_date: "Wed Jan 08 2014 15:49:46 GMT-0800 (PST)",
rent: 3000,
reason: "Test",
_id: "52cc929a90b078e563000033",
implemented: true,
id: "52cc929a90b078e563000033"
}
],
tenants: {
_current: {
__t: "cornerstonesoftware__Tenant",
_first_month_rent_journal: "52cc929a90b078e563000027",
_deposit_journal: "52cc929a90b078e56300002a",
_unit: "52cc929a90b078e563000024",
_property: "52cc929a90b078e56300001b",
ssn: "123-45-6789",
move_in_date: "Tue Jan 07 2014 15:49:46 GMT-0800 (PST)",
rent_due_date: 8,
deposit: 500,
rent: 2000,
core_account: "main-account",
_id: "52cc929a90b078e563000026",
__v: 0,
additional_tenants: [],
notes: [],
balance: -2500,
record_deposit: true,
deposit_paid: false,
status: "current",
contacts: [],
name: {
first: 'Foo',
last: 'Bar'
},
expected_move_out: null,
_related: void 0,
id: "52cc929a90b078e563000026"
},
_former: []
},
rent_controlled: false,
notes: [],
_related: void 0,
id: "52cc929a90b078e563000024"
};
dot.set(obj, 'tenants._former', []);
return obj.tenants._current.name.first.should.equal('Foo');
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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