Class: Guacamole::AqlQuery
Overview
Build an AQL query for ArangoDB
Instance Attribute Summary collapse
-
#aql_fragment ⇒ Object
The AQL fragment to be added into the complete query.
-
#collection ⇒ Object
readonly
The associated collection.
-
#options ⇒ Object
readonly
The additional options.
Attributes inherited from Query
#connection, #example, #mapper
Instance Method Summary collapse
-
#aql_string ⇒ String
Creates an AQL string based on the
aql_fragment
, the collection and model information. -
#bind_parameters ⇒ Hash
Get the bind parameters.
-
#bind_parameters=(bind_parameters) ⇒ Object
Set the bind parameters.
-
#default_options ⇒ Hash
The default options to be set for the query.
- #for_in ⇒ Object
-
#initialize(collection, mapper, options = {}) ⇒ AqlQuery
constructor
Create a new AqlQuery.
-
#perform_mapping? ⇒ Boolean
Should the mapping step be perfomed? If set to false we will return the raw document.
-
#return_as ⇒ String
The RETURN part of the query.
Methods inherited from Query
Constructor Details
#initialize(collection, mapper, options = {}) ⇒ AqlQuery
Create a new AqlQuery
22 23 24 25 26 |
# File 'lib/guacamole/aql_query.rb', line 22 def initialize(collection, mapper, = {}) @collection = collection super(collection.connection.query, mapper) @options = .merge() end |
Instance Attribute Details
#aql_fragment ⇒ Object
The AQL fragment to be added into the complete query
7 8 9 |
# File 'lib/guacamole/aql_query.rb', line 7 def aql_fragment @aql_fragment end |
#collection ⇒ Object (readonly)
The associated collection
10 11 12 |
# File 'lib/guacamole/aql_query.rb', line 10 def collection @collection end |
#options ⇒ Object (readonly)
The additional options
13 14 15 |
# File 'lib/guacamole/aql_query.rb', line 13 def @options end |
Instance Method Details
#aql_string ⇒ String
Creates an AQL string based on the aql_fragment
,
the collection and model information.
46 47 48 49 50 |
# File 'lib/guacamole/aql_query.rb', line 46 def aql_string aql_string = "#{for_in} #{aql_fragment} #{return_as}" Guacamole.logger.debug "[AQL] #{aql_string} | bind_parameters: #{bind_parameters}" aql_string end |
#bind_parameters ⇒ Hash
Get the bind parameters
38 39 40 |
# File 'lib/guacamole/aql_query.rb', line 38 def bind_parameters @options[:bind_vars] end |
#bind_parameters=(bind_parameters) ⇒ Object
Set the bind parameters
31 32 33 |
# File 'lib/guacamole/aql_query.rb', line 31 def bind_parameters=(bind_parameters) @options[:bind_vars] = bind_parameters end |
#default_options ⇒ Hash
The default options to be set for the query
73 74 75 76 77 78 79 |
# File 'lib/guacamole/aql_query.rb', line 73 def { return_as: "RETURN #{model_name}", for_in: "FOR #{model_name} IN #{collection_name}", mapping: true } end |
#for_in ⇒ Object
59 60 61 |
# File 'lib/guacamole/aql_query.rb', line 59 def for_in [:for_in] end |
#perform_mapping? ⇒ Boolean
Should the mapping step be perfomed? If set to false we will return the raw document.
66 67 68 |
# File 'lib/guacamole/aql_query.rb', line 66 def perform_mapping? [:mapping] end |
#return_as ⇒ String
The RETURN part of the query
55 56 57 |
# File 'lib/guacamole/aql_query.rb', line 55 def return_as [:return_as] end |