Skip to content

Instantly share code, notes, and snippets.

@jeffmarshall
Created April 19, 2013 13:38
Show Gist options
  • Save jeffmarshall/5420414 to your computer and use it in GitHub Desktop.
Save jeffmarshall/5420414 to your computer and use it in GitHub Desktop.
I have two constructors in two separate files that have to depend on each other in their methods. Is it okay to put the 'require' call inside the methods that depend on the other models?
// '/models/a.js'
function A(){
this.type = 'a'
}
A.prototype.delete = function deleteA(callback){
var self = this;
self.findAllBs(function(err, res){
res.forEach(function(b){
var b = new B(b);
b.delete();
});
});
}
// '/models/b.js'
function B(){
this.type = 'b'
}
B.prototype.read = function readB(callback){
var self = this;
var myA = new A(self.a)
myA.read(function(err, res){
return callback(null, 'My A:'+ res);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment