Module: Redgraph::NodeModel::GraphManipulation

Defined in:
lib/redgraph/node_model/graph_manipulation.rb

Instance Method Summary collapse

Instance Method Details

#add_relation(type:, node:, properties: nil, allow_duplicates: true) ⇒ Object

Adds a relation between the node and another node.

  • type: type of relation

  • node: the destination node

  • properties: optional properties hash

  • allow_duplicates: if false it will create a relation between two nodes with the same type

    and properties only if not present
    


12
13
14
15
# File 'lib/redgraph/node_model/graph_manipulation.rb', line 12

def add_relation(type:, node:, properties: nil, allow_duplicates: true)
  edge = Edge.new(type: type, src: to_node, dest: node.to_node, properties: properties)
  allow_duplicates ? graph.add_edge(edge) : graph.merge_edge(edge)
end

#query(cmd) ⇒ Object

Runs a custom query on the graph



19
20
21
# File 'lib/redgraph/node_model/graph_manipulation.rb', line 19

def query(cmd)
  self.class.query(cmd)
end