module ActiveGraph::Node::Query::ClassMethods

Public Instance Methods

as(node_var) click to toggle source

Start a new QueryProxy with the starting identifier set to the given argument. This method does not exist within QueryProxy, it can only be called at the class level to create a new QP object. To set an identifier within a QueryProxy chain, give it as the first argument to a chained association.

@example Start a new QueryProxy where the first identifier is set manually.

# Generates: MATCH (s:`Student`), (result_lessons:`Lesson`), s-[rel1:`ENROLLED_IN`]->(result_lessons:`Lesson`)
Student.as(:s).lessons

@param [String, Symbol] node_var A string or symbol to use as the starting identifier. @return [ActiveGraph::Node::Query::QueryProxy]

   # File lib/active_graph/node/query.rb
70 def as(node_var)
71   query_proxy(node: node_var, context: self.name)
72 end
query_as(var, with_labels = true) click to toggle source

Returns a Query object with all nodes for the model matched as the specified variable name

@example Return the registration number of all cars owned by a person over the age of 30

# Generates: MATCH (person:Person), person-[:owned]-car WHERE person.age > 30 RETURN car.registration_number
Person.query_as(:person).where('person.age > 30').match('person-[:owned]-car').return(car: :registration_number)

@param [Symbol, String] var The variable name to specify in the query @param [Boolean] with_labels Should labels be used to build the match? There are situations (neo_id used to filter, an early Cypher match has already filtered results) where including labels will degrade performance. @return [ActiveGraph::Core::Query]

   # File lib/active_graph/node/query.rb
46 def query_as(var, with_labels = true)
47   query_proxy.query_as(var, with_labels)
48 end
query_proxy(options = {}) click to toggle source
   # File lib/active_graph/node/query.rb
56 def query_proxy(options = {})
57   ActiveGraph::Node::Query::QueryProxy.new(self, nil, options)
58 end