I'm new to neo4j i tried to insert a data into neo4j database via node4js but error has occurred any resolve this problem.
我是neo4j的新手,我试图通过node4js将数据插入到neo4j数据库中,但是出现了任何错误都可以解决这个问题。
var express=require("express");
var app=express();
var neo4j=require('neo4j');
var neo4jDB = new neo4j.GraphDatabase('http://localhost:7474/browser');
var crypto=require('crypto');
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: true }))
var appSecret=process.env.APP_SECRET;
app.get('/',function (req,res){
res.send("Hello World");
})
app.get('/index',function(req,res){
res.sendFile('test.html',{'root': __dirname });
})
app.post('/insert',function (req,res){
var email = req.body['email'];
var password = req.body['password'];
var query = [
'CREATE (user:User {newUser})',
'RETURN user'
].join('\n');
var params = {
newUser: {
email: email,
password: password,
}
};
neo4jDB.cypher({
query: query,
params: params
},
function(err,user){
if(err) throw err;
console.log(user);
res.send("Record has been inserted")
});
})
app.listen(8000);
1 个解决方案
#1
3
Your Neo4j server requires an authentication (the default setting), so you have to provide a username and a password to connect to it.
Neo4j服务器需要一个身份验证(默认设置),因此必须提供一个用户名和密码来连接它。
According to the documentation for the "neo4j" npm package, this is done in the URL of the Neo4j server:
根据“neo4j”npm包的文档,这是在neo4j服务器的URL中完成的:
var db = new neo4j.GraphDatabase('http://username:password@localhost:7474');
#1
3
Your Neo4j server requires an authentication (the default setting), so you have to provide a username and a password to connect to it.
Neo4j服务器需要一个身份验证(默认设置),因此必须提供一个用户名和密码来连接它。
According to the documentation for the "neo4j" npm package, this is done in the URL of the Neo4j server:
根据“neo4j”npm包的文档,这是在neo4j服务器的URL中完成的:
var db = new neo4j.GraphDatabase('http://username:password@localhost:7474');