Sha256: 55c288caa59048209a66df4b00d9340f2a50b363d9d688e92983160a1c18b4f9

Contents?: true

Size: 787 Bytes

Versions: 3

Compression:

Stored size: 787 Bytes

Contents

module Redgraph
  module NodeModel
    module GraphManipulation
      # 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
      #
      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

      # Runs a custom query on the graph
      #
      def query(cmd)
        self.class.query(cmd)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redgraph-0.2.3 lib/redgraph/node_model/graph_manipulation.rb
redgraph-0.2.2 lib/redgraph/node_model/graph_manipulation.rb
redgraph-0.2.1 lib/redgraph/node_model/graph_manipulation.rb