Comments (12)
👍 I also need to know this.
from neography.
Not sure what you are asking here actually. You can delete a relationship like so:
new_node1 = @neo.create_node
new_node2 = @neo.create_node
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
@neo.delete_relationship(new_relationship)
new_relationship["end"] points to the new_node2
You mean to delete all relationships of that node?
START max=node:node_auto_index(name="Max")
MATCH (max)-[r?]->()
DELETE r;
That would do it.
I guess we could add a delete relationships method to do this?
Is that what you are asking or something else?
from neography.
Thanks for your response @maxdemarzi. In your example, you build the relationship and then delete it right away. In my case, I don't have a reference to the relationship yet. I need to be able to get a reference to that exact relationship, then pass it to delete_relationship
. Here's the workaround we came up with:
relationship_ids = @neo.execute_script("g.v(#{parent_node.neo_id}).outE('#{relationship_name}').inV.filter { ... }.back(2).id")
relationship_ids.each { |rel_id| @neo.delete_relationship(rel_id) }
It would be great if Neography could encapsulate finding relationship ids as above.
from neography.
This is my problem as well. I never want to create and then immediately delete a relationship. I create it, lose the reference, and then eons later need to delete it.
from neography.
Ah ok.
node1_rels = @neo.get_node_relationships(1)
node1_rels.each { |rel_id| @neo.delete_relationship(rel_id) }
You can also get a specific type or direction for the relationships see:
def get_node_relationships(id, dir = nil, types = nil)
@node_relationships.get(id, dir, types)
end
This is in https://github.com/maxdemarzi/neography/blob/master/lib/neography/rest.rb#L166
from neography.
Awesome, thanks @maxdemarzi !
from neography.
Right, that's pretty much exactly what I pointed to in my original post. The problem with using get_node_relationships
, even with the direction
and types
options, is the number of potential matches returned. I want to get the specific relationship between node1
and node2
- I don't care about any of the other relationships between node1
and other nodes. Here's what I'm envisioning:
rels = @neo.get_node_relationships(node1, node2) # there may be more than one, eg. multiple types
node1_rels.each { |rel_id| @neo.delete_relationship(rel_id) }
Is it really a problem to just be able to specify two nodes and get back the relationship(s) between them? I mean, create_relationship(node1, node2)
creates a relationship between node1
and node2
- why isn't there a complementary function that takes the same arguments to get/delete the same relationship? I admit, I'm pretty new to the graph database world, maybe I'm just misunderstanding the fundamentals.
from neography.
It would be nice if the REST API did that...
GET http://localhost:7474/db/data/node/362/relationships/363 <-- get em all.
GET http://localhost:7474/db/data/node/362/relationships/363/in <-- get all Incoming.
GET http://localhost:7474/db/data/node/362/relationships/363/all/LIKES&HATES <-- for example would get both incoming and outgoing likes & hates rels between these two nodes (if any exist).
Maybe we can add it to Neo4j... or we can cheat and fake it with cypher.
from neography.
Am I losing it or can't we just do this with the traversal part of the REST API?
from neography.
Ok... so I added the ability to just get the relationships between two nodes.
See fd13a05
These should all be possible now. Try it, and let me know if you find something not working.
rels = @neo.get_node_relationships_to(node1, node2)
rels = @neo.get_node_relationships_to(node1, node2, "in")
rels = @neo.get_node_relationships_to(node1, node2, "in", "enemies")
rels = @neo.get_node_relationships_to(node1, node2, "in", ["friends", "enemies"])
rels.each { |rel_id| @neo.delete_relationship(rel_id) }
from neography.
Awesome! Thanks @maxdemarzi , I will test this out soon.
from neography.
Cool, thanks @maxdemarzi!
from neography.
Related Issues (20)
- send authorization token
- Undefined method 'each' for nil:NilClass
- How to use the neo4j graph algorithms using neography?
- config protocol issue "://"
- Getting random SocketError: Connection refused when creating relationships on large import HOT 4
- Ruby gem contains erroneous references HOT 6
- how can I get expanded query results like in browser
- Rake task namespace
- create_spatial_index throws "No index provider 'spatial' found" for Neo4j 3.0 HOT 1
- what is the index name when I create a schema index? HOT 2
- maintaining compatability with Neo4j? HOT 1
- trying to get nodes based on relationship HOT 6
- how do I get the node or nodes related to a start node? HOT 1
- what is the format of the queries for .find?
- I am using Phase2 to get related nodes...where can I find docs on the methods? HOT 2
- how do I create a query of neo4j using the neography ruby gem? HOT 2
- what is the query format for the Phase 2 Nodes? HOT 1
- how do I pass a string for the relationship in a query? HOT 2
- can you clarify what it means Phase 2?
- getting error Neography::NeographyError: NeographyError: when i am using ActiveRecord with neo4j .
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neography.