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

feature: tx should support query methods #905

Open
ChandlerBent opened this issue Jun 8, 2021 · 0 comments
Open

feature: tx should support query methods #905

ChandlerBent opened this issue Jun 8, 2021 · 0 comments

Comments

@ChandlerBent
Copy link

I wrote some unit test and begin tx. I need to query node after I create it on tx.
I will rollback data on unit test end.

Example: match, match_one, nodes, relations

class Transaction(object):
    ...

    @property
    def nodes(self):
        return NodeMatcher(self)

    @property
    def relationships(self):
        return RelationshipMatcher(self)

    def match(self, nodes=None, r_type=None, limit=None):
        return RelationshipMatcher(self).match(nodes=nodes, r_type=r_type).limit(limit)

    def match_one(self, nodes=None, r_type=None):
        matches = self.match(nodes=nodes, r_type=r_type, limit=1)
        rels = list(matches)
        if rels:
            return rels[0]
        else:
            return None

This code is work.

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

No branches or pull requests

1 participant