Nodejs mongoose超出了最大调用堆栈大小

时间:2016-01-17 21:08:43

标签: node.js mongoose

我试图调用集合中的所有元素,并且它超出了最大调用堆栈大小错误。代码如下。

router.get('/users',counsellorValidate, function(req, res, next) {
    users.find({},function(err,user) {
            res.render('counsellor/counsellorHome',{'userData':user,'user':req.session.user});
    });
});

下面给出了数据库模式。

var userSchema = new Schema({
    first_name:{ 
        type: String, 
        required: true 
    },
    last_name:{ 
        type: String, 
        required: true 
    },
    email:{ 
        type: String, 
        required: true,
        unique: true  
    },
    altEmail:{ 
        type: String, 
    },
    password:{ 
        type: String, 
        required: true,
    },
    phone:{ 
        mobile:Number,
        isd:Number,
        std:Number,
        landline:Number
    },
    dob:Date,
    address:{
        line1:String,
        line2:String,
        city:String,
        state:String,
        country:String,
        pin:String
    },
    fb:String,
    twitter:String,
    linkedIn:String,
    blog:String,
    skype:String,
    maritial:String,
    gender:String,
    profile:{
        name:String,
        original_name:String
    },
    summary:String,
    resume:{
        name:String,
        original_name:String
    },
    education: [{
        school_name:String,
        city:String,
        state:String,
        board:String,
        marks:String,
        year:String,
        medium:String,
        specialization:String,
        mode :String
    }],
    scores : {
        gre:Number,
        gmat:Number,
        sat:Number,
        ielts:Number,
        toefl:Number,
        pte:Number
    },
    _email:{
        type:Boolean,
        required:true,
        default:false
    },
    _approved:{
        type:Boolean,
        required:true,
        default:false
    },
});

我尝试过增加堆栈大小,但它会出现分段错误代码转储错误。

1 个答案:

答案 0 :(得分:0)

我设法解决了这个问题。问题在于痛饮。 swig抛出此错误,因为有一个未初始化的变量。