Skip to content

Implemented map function for Record. #494

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
Oct 30, 2019
Merged

Implemented map function for Record. #494

merged 1 commit into from
Oct 30, 2019

Conversation

martin-neotech
Copy link
Contributor

  1. Implemented map function for Record.

  2. Also included is functions for graph Objects.

  3. Made the IDENTIFIER_PROPERTY_ATTRIBUTES more explicit.

  4. Need to implement tests for isPath, isNode, etc

record.map

#469

hi, I would like to add a suggestion that Record will have a map function, it's already have forEach so I think its not too difference.
my use case is doing async stuff inside the forEach and I want to await there

const promises = record.map(async (v) => {
   // ... stuff
   await stuff(v)
   //... more stuff
})

await Promise.all(promises)
which I cant do with forEach,
what I did instead for now is

const promises = Object.values(record.toObject()).map(async (v) => {
   // ... stuff
   await stuff(v)
   //... more stuff
})

await Promise.all(promises)
which is kinda hack

@zhenlineo
Copy link
Contributor

@lutovich Can you help to review this PR :)

Copy link
Contributor

@lutovich lutovich left a comment

Choose a reason for hiding this comment

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

Looks good, made two small comments.
It would also be nice to add tests for isNode, isRelationship, etc.

Copy link
Contributor

@lutovich lutovich left a comment

Choose a reason for hiding this comment

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

LGTM, two small comments

@zhenlineo
Copy link
Contributor

Can you also clean your git commit history to remove unneeded commits such as Merge remote-tracking branch 'origin/4.0' into recordmapfunction
and merge small commits into bigger one commits, such as commits for Update TOOLS.md.

This is needed for anyone else who need to read git history when coding to figure out why you need to make changes at certain lines.

You can use git commands such as rebase to clean up git history.

Added functions for graph Objects.

isRelationship
isUnboundRelationship
isPath
isPathSegment

Made the IDENTIFIER_PROPERTY_ATTRIBUTES more explicit.

Added typescript definitions and tests.

The typescript definition for the map function uses a generic type.
@zhenlineo zhenlineo merged commit 0365f07 into neo4j:4.0 Oct 30, 2019
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.

3 participants