Skip to content
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

Export query result records as JSON #957

Merged
merged 6 commits into from
Aug 30, 2019

Conversation

huboneo
Copy link
Contributor

@huboneo huboneo commented Aug 15, 2019

This PR enables users to export result records as JSON, trying to mimic APOC output as much as possible.

STR

  • Run cypher query (eg. MATCH p = (:Person)-[r]-(:Movie) RETURN p
  • Select "Export JSON" from dropdown

Screenshots

Screenshot 2019-08-15 at 14 12 05

Screenshot 2019-08-15 at 14 12 15

Sample output

See unit tests

} from 'browser/modules/Stream/CypherFrame/helpers'
import { csvFormat } from 'services/bolt/cypherTypesFormatting'
import arrayHasItems from 'shared/utils/array-has-items'

const JSON_EXPORT_INDENT = 2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oskarhane any suggestions for where to put this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to extract this at all imo.

line-height: 30px;
padding: 5px 0 5px 0;
padding: 5px 10px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to do this to fix dropdown

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this to DropdownItem to fix appearance

case neo4j.types.LocalTime:
case neo4j.types.Time:
case neo4j.types.Point:
case neo4j.types.Integer: // not exposed in typings but still there
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be that I should call toInt() for Integers?

- CSS fix
- Export int as Number
- Export Point as GeoJSON
- Reorder and cleanup
@huboneo huboneo force-pushed the feature-export-data-json branch from ab3c3d7 to 8280de0 Compare August 16, 2019 09:28
Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'd like maybe @jexp to have a look at the output to see if that's useful for prospects.

} from 'browser/modules/Stream/CypherFrame/helpers'
import { csvFormat } from 'services/bolt/cypherTypesFormatting'
import arrayHasItems from 'shared/utils/array-has-items'

const JSON_EXPORT_INDENT = 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to extract this at all imo.

@@ -726,4 +727,510 @@ describe('helpers', () => {
])
})
})

describe('recordToJSONMapper', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done on the tests 🎉

}

// could be a Node or Relationship
const type = lowerCase(get(values, 'constructor.name', ''))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From discussion: call this elementType

const type = lowerCase(get(values, 'constructor.name', ''))

if (includes(['relationship', 'node'], type)) {
const labels =
Copy link
Member

@oskarhane oskarhane Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From discussion: Call this type for relationships and keep labels for nodes.

@huboneo
Copy link
Contributor Author

huboneo commented Aug 30, 2019

@oskarhane updated the PR as per your comments

@huboneo huboneo merged commit dcc689b into neo4j:master Aug 30, 2019
@huboneo huboneo deleted the feature-export-data-json branch August 30, 2019 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants