Code Monkey home page Code Monkey logo

Comments (3)

bretcope avatar bretcope commented on June 2, 2024

A better way would be, if you want labels in your query result, you need to specify that using cypher. for example:

MATCH n
RETURN n

would not get you labels, but if specify

MATCH n
RETURN n, labels(n)

then you will get labels. This way we're using cypher instead of another optional parameter, and you wouldn't have to make an extra round-trip to neo4j to get the labels.

The algorithm which parses the query result would need to be intelligent enough to look for column names matching labels(x) and interpret that column to be the labels for column x.

For full compatibility, you would need to parse the original return statement to see if there were any AS statements. For example:

MATCH n
RETURN n AS myNode, labels(n)

In this case, n would not be a column name because it was aliased to myNode, but the only way to know that is to check the original return statement.

As a first pass it probably isn't necessary to worry about this edge case though. You could get it working based on the first example, and then come back to this.

from neo4j-js.

jexp avatar jexp commented on June 2, 2024

And actually you can now create literal maps in cypher, e.g.

MATCH n
RETURN { data : n, labels: labels(n), id: id(n) } as node

from neo4j-js.

billybonks avatar billybonks commented on June 2, 2024

that solves the problem I was having. its not as necessary to code this now

from neo4j-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.