neo4jrb / activegraph

An active model wrapper for the Neo4j Graph Database for Ruby.
http://neo4jrb.io
MIT License
1.4k stars 276 forks source link

Feature request: allow override of default #destroy behavior #1536

Open leviwilson opened 5 years ago

leviwilson commented 5 years ago

Additional information which could be helpful if relevant to your issue:

Code example

When #destroy is called on an Neo4j::ActiveNode model, the default behavior is such that it effectively does a DETACH DELETE.

irb(main):009:0> c.destroy
 CYPHER
  MATCH (n)
  WHERE (ID(n) = {ID_n})
  OPTIONAL MATCH (n)-[r]-()
  DELETE
    n,
    r | {:ID_n=>2100}

For some things this is fine, but in other cases where you desire data integrity this is less than desirable.

Feature Request

It would be beneficial if we were able to specify the default behavior for a given model such that you could make it so it doesn't do a detach delete so that the #destroy will throw an exception if there are relationships to the node.