[Neo] Checking if relationship exists between two nodes

Tobias Ivarsson tobias.ivarsson at neotechnology.com
Mon Apr 26 09:26:42 CEST 2010

On Mon, Apr 26, 2010 at 7:38 AM, Rick Bullotta <
rick.bullotta at burningskysoftware.com> wrote:

> Hi, Tobias.  I was only referring to the case when it was the intent to
> delete the node also.  In that case, you *have* to delete all the
> relationships to the node in order to delete the node.  No worries, it is
> easy enough to implement!

Yes, I understood that. But I think you should be explicit about which
relationship types you *expect* to remove. This means that if the node had
relationships of types that you didn't expect those will not be removed and
an exception will be thrown when you commit the transaction. This is a good
thing, since it helps you detect errors in your code. If for example the
node is part of an in-graph data structure, it would probably have to be
gracefully removed from that data structure, just removing all of the
relationships from the node would probably break the data structure. I would
much prefer the utility methods to aid you by signaling that you forgot to
remove the node, by throwing an exception, than to silently break your data

On Mon, Apr 26, 2010 at 12:08 AM, Niels Hoogeveen <pd_aficionado at hotmail.com
> wrote:

> The moment there is a utility class SomeUtilityClass.delete( Node node,
> RelationshipType... expectedTypes ), the following "unsafe" construct is
> easily written:
> for(RelationshipType rt : graphDb.getRelationshipTypes()){
>  SomeUtilityClass.delete( node, rt );}
Yes, and I will not stop you, I just think that the utilities we endorse
should be utilities that encourage good code (see above).

Tobias Ivarsson <tobias.ivarsson at neotechnology.com>
Hacker, Neo Technology
Cellphone: +46 706 534857

More information about the User mailing list