question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

README examples don't seem to be reflective of how Neo4J returns data

See original GitHub issue

Details

  • Neo4j version: Community 4.0.6
  • Neo4j Mode: Single instance (docker)
  • Driver version: Javascript driver (running in Typescript) 4.1.0
  • Operating system: PopOS (Ubuntu derivative) 20.04

Steps to reproduce

  1. Create node
import { types } from "neo4j-driver";
await session.run(
  "CREATE (a:MyNode { name: $name, date: $date })",
  { name: "Bugsy Manode", date: types.DateTime.fromStandardDate(new Date()) }
);
  1. Try to retrieve node
const result = await session.run("MATCH (n:MyNode) RETURN n");
result.records.forEach((record) => {
  console.log("Got me a node!", record.get("name")
});

Expected behaviour

Should see the following in the console:

Got me a node! Bugsy Manode

Actual behaviour

Get an error saying: (node:55962) UnhandledPromiseRejectionWarning: Neo4jError: This record has no field with key 'name', available key are: [n].

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
2hdddgcommented, Jun 30, 2020

@gfarrell Not sure if you mean that you want all nodes or all properties of a node. Your "“MATCH (n:MyNode) RETURN n” returns all nodes with label MyNode and the each node has it’s properties carried along with them so with this you get both.
node = record.get(0) name = node.properties[“name”]

0reactions
2hdddgcommented, Jun 30, 2020

Yes but instead of iterating from the values in the record you can as well iterate through the properties of the node

Read more comments on GitHub >

github_iconTop Results From Across the Web

RETURN - Cypher Manual - Neo4j
In the RETURN part of your query, you define which parts of the pattern you are interested in. It can be nodes, relationships,...
Read more >
Welcome to the Dark Side: Neo4j Worst Practices (& How to ...
The Dark Side of Graph Data Modeling. Because graphs are schema-less, you might be tempted to ignore its design, to neglect documenting the ......
Read more >
Filtering Query Results - Developer Guides - Neo4j
All of our examples will continue with the graph example we have been using in the previous guides, but include some more data...
Read more >
Limiting MATCH results per row - Knowledge Base - Neo4j
Take an example case using the Movies database. If you needed a query to get all the ... The LIMIT will instead make...
Read more >
Spring Data Neo4j
1, Spring Data Neo4j uses Spring Data Commons and its reflective ... define method parameters as already seen in the preceding examples.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found