I have the following function:
async function getCoordinates(someId) {
var coordinates = {longitude: 0, latitude: 0};
var result = await neo4jsession.writeTransaction(tx =>
tx.run(`MATCH (p:SomeEntity)
WHERE p.some_id = "${someId}"
RETURN p.longitude, p.latitude LIMIT 1`)
);
coordinates.longitude = results.records[0].get("p.longitude");
coordinates.latitude = results.records[0].get("p.latitude");
return coordinates;
}
The problem is, in the above, when I print console.log(result), I see that the returned result doesn't have any Records. However, when I run the query:
MATCH (p:SomeEntity)
WHERE p.some_id = 12345
RETURN p.longitude, p.latitude LIMIT 1
for the same some_id I get the expected result. I have some other functions with queries that are working. I get this issue only with this query.
Since the query is not returning any records, coordinates.longitude = results.records[0].get("p.longitude"); is failing with a TypeError.
some_idis an attribute of a node.some_idis not the internal id of the node. It's a custom attribute. So, this didn't work.