如何在NodeJS中使用Promise.all关闭连接

时间:2019-01-08 09:34:39

标签: node.js neo4j promise

我在NodeJs中使用neo4j驱动程序连接到其数据库。但是,我得到-

Neo4jError :socket hang up

当搜索解决方案时,它说我在查询完成之前关闭了驱动程序。 但是我的代码中没有任何driver.close()或session.close()。请帮助我解决错误。

app.service.js

        const neo4j = require('neo4j-driver').v1;
        const driver = neo4j.driver("bolt://" + neo4jIP + ":" + 
        neo4jPort, 
        neo4j.auth.basic("neo4j", "abc"));
        var session = driver.session();


                       for (i = 0; i < cyphers.length; i++) {


                                queries.push(session.run(cyphers[i]));
                                console.log("after session.run , 
                                CYPHERS, cyphers[i] ", cyphers[i]);


                                Promise.all(queries)
                                    .then(function (results) {

                                        results.forEach(function (result) {

                                        })

                                    })
                                    .catch(function (err) {
                                        console.log("inside catch = " + err);
                                    })
                                    }

查询对象为-

  

session.run之后,CYPHERS,密码[i]匹配   (txnstatus_18:txnstatus_18),其中txnstatus_18.name ='txnStatus_18'   创建(subject_18:subject_18 {name:'subject_18',company:'abc'}),   (txnstatus_18)-[:Parameter]->(subject_18)

     

session.run之后,CYPHERS,密码[i]匹配(return_18:return_18)   其中return_18.name ='return_18'创建   (wfbolckinfo_2:wfbolckinfo_2 {name:'wfBolckInfo_2',company:'abc'}),   (return_18)-[:Parameter]->(wfbolckinfo_2)

     

session.run之后,CYPHERS,密码[i]匹配   (wfbolckinfo_2:wfbolckinfo_2),其中wfbolckinfo_2.name   ='wfBolckInfo_2'创建(targetactivityid_2:targetactivityid_2 {name:'targetActivityId_2',company:'abc'}),   (wfbolckinfo_2)-[:参数]->(targetactivityid_2)

0 个答案:

没有答案