0

Is there an alternative to py2neo's create_unique method for relationships that takes direction into account? Such that uniqueness === same nodes, same label, and same direction?

A solution for Py2neo would be ideal, but I wouldn't be opposed to switching to a more complete driver if there is one.

EDIT: seems like it's a functionality that doesn't exist in Cypher in the first place. I still think it would make a useful driver functionality.

EDIT 2: Cypher let's me use create_unique with direction:

MATCH (b { name: 'Bob' }), (a {name:'Alice'})
CREATE UNIQUE (b)-[r:SWIPED_RIGHT]->(a)
RETURN r

Would be lovely to be able to do the same without writing a raw cypher query.

bsuire
  • 1,383
  • 2
  • 18
  • 27

1 Answers1

1

By default in Py2neo all relationship are created "Outgoing". Use "http://py2neo.org/2.0/essentials.html#py2neo.Rev" for "Incoming" relationships.

Example: - //Creates "Outgoing" Relationship Relationship(Node("FEMALE",name="A"),"FRIEND",Node("FEMALE",name="B"))

//Creates "Incoming" Relationship Relationship(Node("FEMALE",name="A"),Rev("FRIEND"),Node("FEMALE",name="B"))

Sumit
  • 1,400
  • 7
  • 9