How to get node's id with cypher request?

后端 未结 3 2175
时光取名叫无心
时光取名叫无心 2021-02-18 14:13

I\'m using neo4j and making executing this query:

MATCH (n:Person) RETURN n.name LIMIT 5

I\'m getting the names but i need the ids too. Please

相关标签:
3条回答
  • 2021-02-18 14:29

    Not sure how helpful or relevant this is, but when I'm using the NodeJS API the record objects returned from Cypher queries have an identity field on the same level as the properties object (e.g record.get(0).properties, record.get(0).identity). I'm assuming you aren't just doing plain Cypher queries and actually using a driver to send the queries - so you might not have to run another MATCH statement.

    I'm aware that the OP is asking about Cypher specifically - but it might be helpful to other users that stumble upon this question.

    0 讨论(0)
  • 2021-02-18 14:38

    Or you can take a look on the Neo4j Cypher Refcard

    You can get a short look to a lots of functions and patterns you can write.

    And more about functions on The Neo4j Developer Manual - Chapter 3. Cypher - 3.4. Functions

    0 讨论(0)
  • 2021-02-18 14:47

    Since ID isn't a property, it's returned using the ID function.

    MATCH (n:Person) RETURN ID(n) LIMIT 5
    
    0 讨论(0)
提交回复
热议问题