gpt4 book ai didi

javascript - 使用node js在neo4j中创建 Node 时出现错误

转载 作者:太空宇宙 更新时间:2023-11-04 00:29:06 24 4
gpt4 key购买 nike

我的代码!!

var neo4j = require('neo4j-driver').v1;
var express = require('express');
var logger = require('morgan');
var path = require('path');
var bodyParser =require('body-parser');
var app=express();
app.set('views',path.join(__dirname, 'views'));
app.set('view engine','ejs');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(express.static(path.join(__dirname,'public')));
var driver = neo4j.driver("bolt://localhost:7687", neo4j.auth.basic("Novasys", "123456"));
var session = driver.session();
app.get('/', function(req,res){
session
.run('MATCH (n:Movie) RETURN n LIMIT 30')
.then(function(result){
var moviearr = [];
result.records.forEach(function(record){
moviearr.push({enter code here
id: record._fields[0].identity.low,
title: record._fields[0].properties.title,
released: record._fields[0].properties.released
});
});

session
.run('MATCH (n:Person) RETURN n LIMIT 25')
.then(function(result2){
var personArr = [];
result2.records.forEach(function(record){
personArr.push({
id: record._fields[0].identity.low,
name: record._fields[0].properties.name
});
});
res.render('index', {
movies: moviearr,
persons: personArr
});
})
.catch(function(err){
console.log(err);
});
})
.catch(function(err){
console.log(err);
});
});

app.post('/movie/add',function(req,res,next){
var title = req.body.title;
var released = req.body.released;

session
.run('CREATE(n:Movie {title:{titleParam}, released:{releasedParam}}) RETURN n.title',{titleParam:title, releasedParam:released})
.then(function(result){
res.redirect();
session.close();
})
.catch(function(err){
console.log(err);
});

res.redirect('/');

});
app.listen(4000);
console.log('Server started on port 4000');

module.exports=app; **strong text**

出现错误!!

类型错误:无法读取未定义的属性“名称” 在 B:\nodejs\newp\app.js:75:30 在 Layer.handle [作为handle_request] (B:\nodejs\newp\node_modules\express\lib\router\layer.js:95:5) 接下来 (B:\nodejs\newp\node_modules\express\lib\router\route.js:131:13) 在 Route.dispatch (B:\nodejs\newp\node_modules\express\lib\router\route.js:112:3) 在 Layer.handle [作为handle_request] (B:\nodejs\newp\node_modules\express\lib\router\layer.js:95:5) 在 B:\nodejs\newp\node_modules\express\lib\router\index.js:277:22 在 Function.process_params (B:\nodejs\newp\node_modules\express\lib\router\index.js:330:12) 接下来 (B:\nodejs\newp\node_modules\express\lib\router\index.js:271:10) 在serveStatic (B:\nodejs\newp\node_modules\serve-static\index.js:75:16) 在 Layer.handle [作为handle_request] (B:\nodejs\newp\node_modules\express\lib\router\layer.js:95:5)

谁能帮我解决这个问题。我是 Node js 和 Neo4j 的新手。

提前致谢

最佳答案

☼你好,

您的 Neo4j 数据库中有“Person”标签吗?

 session
.run('MATCH (n:Person) RETURN n LIMIT 25')

您尝试过:

session
.run('MATCH (n:Actor) RETURN n LIMIT 25')

我想你举了这个例子here ,但他们使用“电影”和“ Actor ”标签

关于javascript - 使用node js在neo4j中创建 Node 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41696461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com