My Code!!
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**
getting error!!
TypeError: Cannot read property 'name' of undefined at B:\nodejs\newp\app.js:75:30 at Layer.handle [as handle_request] (B:\nodejs\newp\node_modules\express\lib\router\layer.js:95:5) at next (B:\nodejs\newp\node_modules\express\lib\router\route.js:131:13) at Route.dispatch (B:\nodejs\newp\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (B:\nodejs\newp\node_modules\express\lib\router\layer.js:95:5) at B:\nodejs\newp\node_modules\express\lib\router\index.js:277:22 at Function.process_params (B:\nodejs\newp\node_modules\express\lib\router\index.js:330:12) at next (B:\nodejs\newp\node_modules\express\lib\router\index.js:271:10) at serveStatic (B:\nodejs\newp\node_modules\serve-static\index.js:75:16) at Layer.handle [as handle_request] (B:\nodejs\newp\node_modules\express\lib\router\layer.js:95:5)
Can anyone help me in solving this. I am new to node js as well as neo4j.
Thanks in Advance