Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-22-2019 11:29 AM
I have the below code where it runs multiple statements, First Statement should return a result which is used by Second Statement , it is a call from android app .
return session.writeTransaction(wrte=>{
let r : any
if(context.auth){
//This Statement returns ID of the node
wrte.run('MATCH (p:Person{identity:{identity}}) CREATE (p)-[po:POST]->(a:Post{post:{post},userName:{userName}}) RETURN ID(a)',
{identity: context.auth.uid, post: data.post, userName: context.auth.token.name })
}
return r as neo4j.v1.StatementResult
})
//how to get the ID from the Last Statement
.then((val) => session.readTransaction(read => {
console.log(val.records[0].get(0))
return read.run('MATCH (p:Post) WHERE id(p) = {any} RETURN p',{any: val.records[0].get(0)})
}))
.then(result => {
session.close();
driver.close()
console.log(result)
var singleRecord = result.records[0]
var dat = singleRecord.get(0)
if(result.records[0] == null){
return null
} else {
return {
"post": dat.properties.post,
"userName":dat.properties.userName,
}
}
}).catch(error => {
session.close()
console.log(error)
driver.close()
throw new functions.https.HttpsError(error,"some error");
})
});
console.log(val.records[0].get(0))
returns undefined, how to properly pass results and how to retreive ID?
09-22-2019 08:00 PM
Why do you have this in two separate statements? You could easily just return p
from the first statement.
09-22-2019 08:44 PM
i tried everything but it returns undefined value, may i am doing something wrong?
09-22-2019 11:29 PM
I just forgot to return the transaction, now it works.
All the sessions of the conference are now available online