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

Pattern config with variables #310

Merged
merged 23 commits into from
Apr 30, 2024
Merged

Pattern config with variables #310

merged 23 commits into from
Apr 30, 2024

Conversation

angrykoala
Copy link
Member

@angrykoala angrykoala commented Feb 23, 2024

This PR adds non-breaking support for #300, allowing for plain variables to be used in Cypher Patterns

For example:

const a = new Cypher.Variable();
const rel = new Cypher.Variable();
const b = new Cypher.Variable();

const pattern = new Cypher.Pattern({ variable: a, labels: ["Movie"] })
    .related({ variable: rel, type: "ACTED_IN" })
    .to({ variable: b });

instead of the current:

const a = new Cypher.Node({labels: ["Movie"]})
const rel = new Cypher.Relationship({type: "ACTED_IN"})
const b = new Cypher.Node()

const pattern = new Cypher.Pattern(a).related(rel).to(b);

Copy link

changeset-bot bot commented Feb 23, 2024

🦋 Changeset detected

Latest commit: f766f84

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@neo4j/cypher-builder Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@angrykoala angrykoala force-pushed the variables-in-pattern branch 2 times, most recently from 519644d to 0aab62f Compare February 29, 2024 13:07
@angrykoala angrykoala mentioned this pull request Feb 29, 2024
21 tasks
@angrykoala angrykoala marked this pull request as ready for review March 1, 2024 16:44
super(node);

// Emulates not having a variable if the config option is passed without one
if (!(nodeConfig instanceof NodeRef) && !nodeConfig.variable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can remove this and assign this.withVariable as Boolean(nodeConfig.variable) in the branch condition below

@angrykoala angrykoala changed the title WIP pattern config Pattern config with variables Apr 25, 2024
@angrykoala angrykoala force-pushed the variables-in-pattern branch from 1a20c1e to 98a8b2f Compare April 26, 2024 10:38
Copy link

@angrykoala angrykoala merged commit 7db7c2f into main Apr 30, 2024
10 checks passed
@angrykoala angrykoala deleted the variables-in-pattern branch April 30, 2024 09:41
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.

2 participants