cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Params on javascript

Hello,
I´m sure that someone of you can help me with this issue.
I´m trying to create a node property with "params", but I must be missing something, because nothing happens. I neither received a console.log error, nor the param is working properly.
I could console.log the requested variables, so that the request of the app is working, too.

Thank you for your help.

app.post("/person/originalname/add", function(req, res) {
var originalname = req.body.originalname;
var id = req.body.id;

session
.run("MATCH (n) where id(n) = $idParam SET n.original_name = $originalParam RETURN n", {
originalParam: originalname,
idParam: id
}
)
.then(function(result) {
res.redirect('/');

})
.catch(function(error) {
  console.log(error);
});

});

1 ACCEPTED SOLUTION

I found the solution. In this case I needed to build a props{} to set it as property:

app.post("/person/originalname/add", function(req, res) {
var originalname = req.body.originalname;
var id = req.body.id;

session
.run("MATCH (n) where id(n) = $idParam SET n = $props", {
props: {
"original_name": originalname
},
idParam: id
})

.then(function(result) {
  res.redirect('/');

})
.catch(function(error) {
  console.log(error);

});

});

Thank you very much

View solution in original post

2 REPLIES 2

Hi @arturo.guerrero ,

Tracking down these kinds of issues can be tricky. What happens when you directly run the query using Neo4j Browser? It can be helpful to debug in Neo4j Browser, both with and without parameters, then migrate the working query back into your app.

Best,
ABK

I found the solution. In this case I needed to build a props{} to set it as property:

app.post("/person/originalname/add", function(req, res) {
var originalname = req.body.originalname;
var id = req.body.id;

session
.run("MATCH (n) where id(n) = $idParam SET n = $props", {
props: {
"original_name": originalname
},
idParam: id
})

.then(function(result) {
  res.redirect('/');

})
.catch(function(error) {
  console.log(error);

});

});

Thank you very much