neo4j cypher不会更新数据库

时间:2018-02-01 02:51:19

标签: javascript neo4j cypher

以下代码获取错误"结果未定义" (最后一次错误陷阱)请帮助:

try {
    var driver = neo4j.driver("bolt://localhost:7474", neo4j.auth.basic(userName, passWord));
} catch (err) {
    alert(err.message);
}
const session = driver.session();
const personName = 'Alice';

try {
    const resultPromise = session.run('CREATE (a:Person {name: $name}) RETURN a', {
        name: personName
    });
} catch (err) {
    alert(err.message);
}
try {
    resultPromise.then(
        result => {
            session.close();
            const singleRecord = result.records[0];
            const node = singleRecord.get(0);
            console.log(node.properties.name);
            driver.close();
        }
    );
} catch (err) {
    alert(err.message);
}

1 个答案:

答案 0 :(得分:0)

我认为错误是因为您在Neo4j的http端口(7474)上使用了java bolt驱动程序。

只需更改此连接网址:neo4j.driver("bolt://localhost:7687", neo4j.auth.basic(userName, passWord))