节点js mongoerror'写ECONNRESET'

时间:2016-12-22 08:40:26

标签: node.js mongodb mongoose

节点js 中创建新文档时,会给出写入ECONNRESET的MongoError。 创建新文档时,以下是控制台中的错误

  

错误:添加新的agreementTemplate时出错!错误:   {“name”:“MongoError”,“message”:“写ECONNRESET”}

以下是创建错误的控制器功能。

wrapper

创建协议模板时会导致错误,此处服务功能

memorize

和createModel函数如下。

function addSubChapter(req, res) {
    logger.debug('Processing request for creating a new agreement.');
    console.log(req.body);
    async.waterfall([
        function (callback) {
            agreementService.getAgreementTemplate( callback);
        },
        function (data, callback) {
            agreementTmplService.AgreementTemplateSetDefaultFalse(function(err, result){
                callback(null, data);
            });
        },
        function (data, callback) {

            var agreementTemplate =data.result[0];
            var chapter ={
                         name: req.body.name
                        }

            agreementTemplate = agreementTemplate.toObject(); // swap for a plain javascript object instance
            delete agreementTemplate["_id"];
            agreementTemplate.createdBy= req.body.user;
            agreementTemplate.created= new Date();
            //agreementTemplate.Chapters.push(chapter);
            var chapters = agreementTemplate.Chapters;
            for(var i=0;i<chapters.length; i++){
                if(chapters[i].name == req.body.chapter){
                    var subChap ={
                        name: req.body.name
                    }
                    chapters[i].subChapters.push(subChap);
                }
            }
            console.log('----------------------');
            console.log(agreementTemplate);
            agreementService.createAgreementTemplate(agreementTemplate, callback);
        },
        function (data, callback) {
            agreementTmplService.addSubChapter(req.body, callback);
        }
    ], function (err, result) {
        utils.processResponse(err, result, res);
    });
}

0 个答案:

没有答案