Class: ROM::Neo4j::Commands::CreateNode

Inherits:
Commands::Create
  • Object
show all
Defined in:
lib/rom/neo4j/commands.rb

Overview

Creates a new node

Creates a new node in the graph with given properties. Any labels configured on the command will also be applied to the node.

Examples:

class CreateCity < ROM::Commands::Create[:neo4j]
  input Hash
  labels :City
  result :one
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.optionsObject



22
23
24
# File 'lib/rom/neo4j/commands.rb', line 22

def self.options
  super.merge!(labels: labels)
end

Instance Method Details

#create_node(properties, labels) ⇒ Object



33
34
35
36
# File 'lib/rom/neo4j/commands.rb', line 33

def create_node(properties, labels)
  result = relation.dataset.session.create_node(properties, labels)
  result.props          
end

#execute(properties) ⇒ Object



26
27
28
29
30
31
# File 'lib/rom/neo4j/commands.rb', line 26

def execute(properties)
  node_args = [properties]
  node_args << [labels].flatten if labels

  create_node(*node_args)
end