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.5 to 0.7.6

28

index.js

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

var Q, dot, mongoose;
var Q, dot, mongoose, _;

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

_ = require('underscore');
module.exports = function(schema, options) {

@@ -42,14 +44,16 @@ schema.virtual('_related').get(function() {

};
schema.methods.populate = function(fields, callback) {
var _this = this;
return mongoose.Document.prototype.populate.apply(this, [
fields, function(err, doc) {
if (!err) {
_this.$__movePopulated();
return callback(err, doc);
} else {
return callback(err, doc);
}
schema.methods.populate = function() {
var args, callback,
_this = this;
args = _.values(arguments);
callback = args.pop();
args.push(function(err, doc) {
if (!err) {
_this.$__movePopulated();
return callback(err, doc);
} else {
return callback(err, doc);
}
]);
});
return mongoose.Document.prototype.populate.apply(this, args);
};

@@ -56,0 +60,0 @@ schema.methods.cascadeSave = function(callback, config) {

{
"name": "cascading-relations",
"version": "0.7.5",
"version": "0.7.6",
"description": "Alternate populate/save/delete functionality for mongoose to allow for cascading relations",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -366,3 +366,3 @@ var barClass, barSchema, bazClass, bazSchema, dot, fooClass, fooSchema, mongoose, relations, should;

});
return it('should rearrange when running populate on document rather than query', function(done) {
it('should rearrange when running populate on document rather than query', function(done) {
var foo,

@@ -394,2 +394,29 @@ _this = this;

});
return it('should handle doc populate with nested relations', function(done) {
var foo,
_this = this;
foo = new fooClass({
title: 'My Foo',
_related: {
multi: {
_bar: {
title: 'First Bar'
}
}
}
});
return foo.cascadeSave(function(err, res) {
return fooClass.findById(res._id, function(err, foo) {
return foo.populate('multi._bar', function(err, foo) {
should.exist(foo._related);
should.exist(foo._related.multi);
should.exist(foo._related.multi._bar);
foo._related.multi._bar.title.should.equal('First Bar');
console.log('FOO:', foo.toObject());
foo._related.multi._bar._id.toString().should.equal(foo.multi._bar.toString());
return done();
});
});
});
});
});

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