You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe this is coming from a lack of understanding of how it's supposed to work, but I can't seem to map multiple relationships & use cascadeSave():
varmongoose=require('mongoose');varcascadingRelations=require('cascading-relations');mongoose.connect('mongodb://localhost/relationships');varsShow=newmongoose.Schema({_id: Number,// the key in the other databasetitle: String,// the nameslug: String// can be used to get URL, images, etc});varsEpisode=newmongoose.Schema({_id: Number,// the key in the other databasetitle: String,// the title of this episodeseason: Number,// the seasonepisode: Number,// the episodeurl: String,// URL for downloading thisshow: {type: Number,ref: 'Show',$through: 'episodes'}});varsUser=newmongoose.Schema({email: {required:true,type:String,unique:true},watched: [{type: Number,ref: 'Episode',$through:'watched'}],ignored: [{type: Number,ref: 'Episode',$through:'ignored'}],collected: [{type: Number,ref: 'Episode',$through:'collected'}],subscriptions: [{type: Number,ref: 'Show',$through:'subscribed'}]});sUser.plugin(cascadingRelations);sEpisode.plugin(cascadingRelations);sShow.plugin(cascadingRelations);varUser=mongoose.model('User',sUser);varShow=mongoose.model('Show',sShow);varEpisode=mongoose.model('Episode',sEpisode);varuser=newUser({email: '[email protected]'});varshow=newShow({_id: 481,title: 'Game of Thrones',slug: 'game-of-thrones'});show.save();user._related={subscribed: [show]};user._related.ignored=[{"_id": 45305,"show": 481,"title": "Game of Thrones S03E09 HDTV x264-EVOLVE","season": 3,"episode": 9,"url": "magnet:?xt=..."},{"_id": 44337,"show": 481,"title": "Game of Thrones S03E05 720p HDTV x264-IMMERSE","season": 3,"episode": 5,"url": "magnet:?xt=..."}];user._related.collected=[{"_id": 55200,"show": 481,"title": "Game of Thrones S04E06 HDTV x264-KILLERS","season": 4,"episode": 6,"url": "magnet:?xt=..."}];user._related.watched=[{"_id": 43700,"show": 481,"title": "Game of Thrones S03E02 720p HDTV x264-IMMERSE","season": 3,"episode": 2,"url": "magnet:?xt=..."}];user.cascadeSave();
I get this:
...node_modules/cascading-relations/node_modules/q/q.js:514
var deferred = object_create(defer.prototype);
^
RangeError: Maximum call stack size exceeded
The text was updated successfully, but these errors were encountered:
Just from your diagram it looks like you may have recursion going on. I didn't consider that when creating the package as I traditionally used it for hierarchical relations.
Maybe this is coming from a lack of understanding of how it's supposed to work, but I can't seem to map multiple relationships & use
cascadeSave()
:I get this:
The text was updated successfully, but these errors were encountered: