Module: ActiveGraph::Node::Query

Extended by:
ActiveSupport::Concern
Included in:
ActiveGraph::Node
Defined in:
lib/active_graph/node/query.rb,
lib/active_graph/node/query/query_proxy.rb,
lib/active_graph/node/query/query_proxy/link.rb,
lib/active_graph/node/query/query_proxy_methods.rb,
lib/active_graph/node/query/query_proxy_enumerable.rb,
lib/active_graph/node/query/query_proxy_eager_loading.rb,
lib/active_graph/node/query/query_proxy_find_in_batches.rb,
lib/active_graph/node/query/query_proxy_methods_of_mass_updating.rb,
lib/active_graph/node/query/query_proxy_eager_loading/association_tree.rb

Overview

Helper methods to return ActiveGraph::Core::Query objects. A query object can be used to successively build a cypher query

person.query_as(:n).match('n-[:friend]-o').return(o: :name) # Return the names of all the person's friends

Defined Under Namespace

Modules: ClassMethods, QueryProxyEagerLoading, QueryProxyEnumerable, QueryProxyFindInBatches, QueryProxyMethods, QueryProxyMethodsOfMassUpdating Classes: QueryProxy

Instance Method Summary collapse

Instance Method Details

#as(node_var) ⇒ ActiveGraph::Node::Query::QueryProxy

Starts a new QueryProxy with the starting identifier set to the given argument and QueryProxy source_object set to the node instance. This method does not exist within QueryProxy and can only be used to start a new chain.

Examples:

Start a new QueryProxy chain with the first identifier set manually

# Generates: MATCH (s:`Student`), (l:`Lesson`), s-[rel1:`ENROLLED_IN`]->(l:`Lesson`) WHERE ID(s) = $neo_id_17963
student.as(:s).lessons(:l)

Parameters:

  • node_var (String, Symbol)

    The identifier to use within the QueryProxy object

Returns:



31
32
33
# File 'lib/active_graph/node/query.rb', line 31

def as(node_var)
  self.class.query_proxy(node: node_var, source_object: self).match_to(self)
end

#query_as(node_var) ⇒ ActiveGraph::Core::Query

Returns a Query object with the current node matched the specified variable name

Examples:

Return the names of all of Mike’s friends

# Generates: MATCH (mike:Person), mike-[:friend]-friend WHERE ID(mike) = 123 RETURN friend.name
mike.query_as(:mike).match('mike-[:friend]-friend').return(friend: :name)

Parameters:

  • node_var (Symbol, String)

    The variable name to specify in the query

Returns:



18
19
20
# File 'lib/active_graph/node/query.rb', line 18

def query_as(node_var)
  self.class.query_as(node_var, false).where("elementId(#{node_var})" => neo_id)
end