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

How can update / delete a node from layer ? #19

Open
dfabreguette opened this issue Jul 10, 2017 · 2 comments
Open

How can update / delete a node from layer ? #19

dfabreguette opened this issue Jul 10, 2017 · 2 comments

Comments

@dfabreguette
Copy link
Contributor

Hi,
I'm using your gem to make "withinDistance" spatial queries with rails and neo4jrb gem.
Here's my problem, I attached an after_save callback that calls the "add_to_spatial_layer" method to add the node to the layer.
The thing is, if I update the node, it re-calls the method to update the index accordingly to the new location of the node and it actually recreates a new index relationship each time I save the node which leads me to many relationships ! (see screenshot)
image
How can I do make sure to remove old relationship before creating a new one ? Is there something done in this gem to do that ?

@dfabreguette
Copy link
Contributor Author

For now I'm using this

myNode.match("(a)-[r:RTREE_REFERENCE]-(b)").delete(:r)

It does the job but I'm not sure this is a good practice !

@cheerfulstoic
Copy link
Contributor

I don't use this gem, but I maintain the neo4j gem, and if you are using ActiveNode you can use the unique option on associations or creates_unique in ActiveRel

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

2 participants