The following TypeError cropped up in some old code.
TypeError: Object #
The Model that was affecte
It's known node.js issue. It means that you have looping require somewhere in your code and node.js forbids it.
The right way to do it is by using mongoose.model
method. So, instead of UserModel
variable you shall use mongoose.model('UserModel')
. So, when findSomeUsers
will be called mondoose will fetch UserModel
and invoke its find
method.
GroupSchema.statics.findSomeUsers = function(group, callback) {
this.find({name : session_user._id}, function(err, groups) {
mongoose.model('UserModel').find({_id : {$in : group.users}}, function(err,patients) {
// do magic
});
});
};