module Neoon::Cypher::Node::Operations

Public Instance Methods

create_node()
Alias for: save_node
delete_node() click to toggle source
# File lib/neoon/cypher/node/operations.rb, line 31
        def delete_node
          cypher_query = <<-CYPHER
            MATCH node:#{label}
            WHERE node._id = #{id}
            DELETE node
          CYPHER
          cypherable(:query => cypher_query)
        end
find_node() click to toggle source
# File lib/neoon/cypher/node/operations.rb, line 6
        def find_node
          cypher_query = <<-CYPHER
            MATCH node:#{label} WHERE node._id = #{id}
            RETURN node
          CYPHER
          cypherable(:query => cypher_query)
        end
save_node() click to toggle source
# File lib/neoon/cypher/node/operations.rb, line 14
        def save_node
          # since you can't update a constrain with same value
          # we have to remove the node and re-create it
          # other way ???
          delete_node unless (label.constantize.respond_to?(:neo_schema_index_keys) ? label.constantize.neo_schema_index_keys : Neoon::Cypher::Query.new(label).list_indexes).select{|k,v| v=='UNIQUENESS'}.empty?

          cypher_query = <<-CYPHER
            MERGE (node:#{label} { _id: #{id} })
            ON CREATE node SET node = {props}
            ON MATCH node SET node = {props}
            RETURN node
          CYPHER
          cypherable(:query => cypher_query, :args => {:props => args})
        end
Also aliased as: update_node, create_node
update_node()
Alias for: save_node