Nodes

tijmenb edited this page Mar 21, 2014 · 6 revisions

Create nodes

@neo.create_node                                           # Create an empty node
@neo.create_node("age" => 31, "name" => "Max")             # Create a node with some properties
@neo.create_unique_node(index_name, key, unique_value,     # Create a unique node
                        {"age" => 31, "name" => "Max"})    # this needs an existing index

Create multiple nodes at once:

nodes = @neo.create_nodes(5)                                              # Create 5 empty nodes
nodes = @neo.create_nodes_threaded(5)                                     # Create 5 empty nodes using threads
nodes = @neo.create_nodes([{"age" => 31, "name" => "Max"},
                           {"age" => 24, "name" => "Alex"}])              # Create two nodes with properties
nodes = @neo.create_nodes_threaded([{"age" => 31, "name" => "Max"},
                                    {"age" => 24, "name" => "Alex"}])     # Create two nodes with properties threaded

Get nodes

Get single nodes:

@neo.get_root                                              # Get the root node
@neo.get_node(123)                                       # Get a node and its properties

Get multiple nodes:

nodes = @neo.get_nodes([17,86,397,33])                                    # Get four nodes by their id

And also:

one_set_nodes = @neo.create_nodes(3)
another_node = @neo.create_node("age" => 31, "name" => "Max")
nodes = @neo.get_nodes([one_set_nodes, another_node])                     # Get four nodes

Delete nodes

@neo.delete_node(node2)                                    # Delete an unrelated node
@neo.delete_node!(node2)                                   # Delete a node and all its relationships