Skip to content

Added: Record.toObject() to transform a Record into an Object #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2016
Merged

Added: Record.toObject() to transform a Record into an Object #100

merged 1 commit into from
Jun 27, 2016

Conversation

legraphista
Copy link
Contributor

There are cases when you want to:

RETURN { a: 1, b: true, c: 'Hello World' } AS data 

and you don't want to

const data =  {
   a: record.get('a'),
   b: record.get('b'),
   c: record.get('c')
};

so you can just

const data = record.toObject();

@legraphista legraphista changed the title Added: Record.toObject() to transform a Record into and Object Added: Record.toObject() to transform a Record into an Object Jun 26, 2016
@legraphista
Copy link
Contributor Author

This feature may not make sense in other languages, but accessing data fields via a .get() method is more Java-esc and not so Javascript friendly.

@oskarhane
Copy link
Member

+1 on this. Good stuff.

@pontusmelke pontusmelke merged commit ab0120f into neo4j:1.1 Jun 27, 2016
@legraphista legraphista deleted the feature/record-toObject-method branch July 22, 2016 07:48
@brian-gates
Copy link
Contributor

I love this feature, but I suspect it requires (or would greatly benefit by) recursion.

e.g. I suspect this query will still produce Node and Rel objects:

MATCH (n)-[r]-()
with n, r limit 1
return { node: n, rel: r } as data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants