Reputation: 5389
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
.
Upvotes: 0
Views: 169
Reputation: 2135
there may two concern
are you sure some_id is not "id of node" ? to match id of node (auto generated id) we use id(node)=12345 syntax
make sure ${someId} is a numeric value may be you are comparing numeric to string. remove quote if some_id is numeric
Upvotes: 1