Class: Arango::AQL

Inherits:
Object
  • Object
show all
Includes:
Database_Return, Helper_Error, Helper_Return
Defined in:
lib/AQL.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Database_Return

#database=

Methods included from Helper_Return

#return_delete, #return_directly?, #return_element

Methods included from Helper_Error

#satisfy_category?, #satisfy_class?, #warning_deprecated

Constructor Details

#initialize(query:, database:, count: nil, batchSize: nil, cache: nil, memoryLimit: nil, ttl: nil, bindVars: nil, failOnWarning: nil, profile: nil, maxTransactionSize: nil, skipInaccessibleCollections: nil, maxWarningCount: nil, intermediateCommitCount: nil, satelliteSyncWait: nil, fullCount: nil, intermediateCommitSize: nil, optimizer_rules: nil, maxPlans: nil) ⇒ AQL

Returns a new instance of AQL.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/AQL.rb', line 9

def initialize(query:, database:, count: nil, batchSize: nil, cache: nil,
  memoryLimit: nil, ttl: nil, bindVars: nil, failOnWarning: nil,
  profile: nil, maxTransactionSize: nil, skipInaccessibleCollections: nil,
  maxWarningCount: nil, intermediateCommitCount: nil,
  satelliteSyncWait: nil, fullCount: nil, intermediateCommitSize: nil,
  optimizer_rules: nil, maxPlans: nil)
  satisfy_class?(query, [String])
  @query = query
  assign_database(database)

  @count       = count
  @batchSize   = batchSize
  @cache       = cache
  @memoryLimit = memoryLimit
  @ttl         = ttl
  @bindVars    = bindVars

  @quantity = nil
  @hasMore  = false
  @id       = ""
  @result   = []
  @options  = {}
  # DEFINE
  ["failOnWarning", "profile", "maxTransactionSize",
  "skipInaccessibleCollections", "maxWarningCount", "intermediateCommitCount",
  "satelliteSyncWait", "fullCount", "intermediateCommitSize",
  "optimizer_rules", "maxPlans"].each do |param_name|
    param = eval(param_name)
    set_option(param, param_name)
    define_singleton_method("#{param_name}=") do |value|
      set_option(value, param_name)
    end
  end
end

Instance Attribute Details

#batchSizeObject Also known as: size

DEFINE ===



46
47
48
# File 'lib/AQL.rb', line 46

def batchSize
  @batchSize
end

#bindVarsObject

DEFINE ===



46
47
48
# File 'lib/AQL.rb', line 46

def bindVars
  @bindVars
end

#cacheObject

DEFINE ===



46
47
48
# File 'lib/AQL.rb', line 46

def cache
  @cache
end

#cachedObject (readonly)

Returns the value of attribute cached.



47
48
49
# File 'lib/AQL.rb', line 47

def cached
  @cached
end

#countObject

DEFINE ===



46
47
48
# File 'lib/AQL.rb', line 46

def count
  @count
end

#databaseObject (readonly)

Returns the value of attribute database.



47
48
49
# File 'lib/AQL.rb', line 47

def database
  @database
end

#extraObject (readonly)

Returns the value of attribute extra.



47
48
49
# File 'lib/AQL.rb', line 47

def extra
  @extra
end

#failOnWarningObject (readonly)

Returns the value of attribute failOnWarning.



47
48
49
# File 'lib/AQL.rb', line 47

def failOnWarning
  @failOnWarning
end

#fullCountObject (readonly)

Returns the value of attribute fullCount.



47
48
49
# File 'lib/AQL.rb', line 47

def fullCount
  @fullCount
end

#hasMoreObject (readonly)

Returns the value of attribute hasMore.



47
48
49
# File 'lib/AQL.rb', line 47

def hasMore
  @hasMore
end

#idObject (readonly)

Returns the value of attribute id.



47
48
49
# File 'lib/AQL.rb', line 47

def id
  @id
end

#idCacheObject (readonly)

Returns the value of attribute idCache.



47
48
49
# File 'lib/AQL.rb', line 47

def idCache
  @idCache
end

#intermediateCommitCountObject (readonly)

Returns the value of attribute intermediateCommitCount.



47
48
49
# File 'lib/AQL.rb', line 47

def intermediateCommitCount
  @intermediateCommitCount
end

#intermediateCommitSizeObject (readonly)

Returns the value of attribute intermediateCommitSize.



47
48
49
# File 'lib/AQL.rb', line 47

def intermediateCommitSize
  @intermediateCommitSize
end

#maxPlansObject (readonly)

Returns the value of attribute maxPlans.



47
48
49
# File 'lib/AQL.rb', line 47

def maxPlans
  @maxPlans
end

#maxTransactionSizeObject (readonly)

Returns the value of attribute maxTransactionSize.



47
48
49
# File 'lib/AQL.rb', line 47

def maxTransactionSize
  @maxTransactionSize
end

#maxWarningCountObject (readonly)

Returns the value of attribute maxWarningCount.



47
48
49
# File 'lib/AQL.rb', line 47

def maxWarningCount
  @maxWarningCount
end

#optimizer_rulesObject (readonly)

Returns the value of attribute optimizer_rules.



47
48
49
# File 'lib/AQL.rb', line 47

def optimizer_rules
  @optimizer_rules
end

#optionsObject

DEFINE ===



46
47
48
# File 'lib/AQL.rb', line 46

def options
  @options
end

#profileObject (readonly)

Returns the value of attribute profile.



47
48
49
# File 'lib/AQL.rb', line 47

def profile
  @profile
end

#quantityObject

DEFINE ===



46
47
48
# File 'lib/AQL.rb', line 46

def quantity
  @quantity
end

#queryObject

DEFINE ===



46
47
48
# File 'lib/AQL.rb', line 46

def query
  @query
end

#resultObject (readonly)

Returns the value of attribute result.



47
48
49
# File 'lib/AQL.rb', line 47

def result
  @result
end

#satelliteSyncWaitObject (readonly)

Returns the value of attribute satelliteSyncWait.



47
48
49
# File 'lib/AQL.rb', line 47

def satelliteSyncWait
  @satelliteSyncWait
end

#serverObject (readonly)

Returns the value of attribute server.



47
48
49
# File 'lib/AQL.rb', line 47

def server
  @server
end

#skipInaccessibleCollectionsObject (readonly)

Returns the value of attribute skipInaccessibleCollections.



47
48
49
# File 'lib/AQL.rb', line 47

def skipInaccessibleCollections
  @skipInaccessibleCollections
end

#ttlObject

DEFINE ===



46
47
48
# File 'lib/AQL.rb', line 46

def ttl
  @ttl
end

Instance Method Details

#destroyObject



132
133
134
# File 'lib/AQL.rb', line 132

def destroy
  @database.request("DELETE", "_api/cursor/#{@id}")
end

#executeObject

EXECUTE QUERY ===



108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/AQL.rb', line 108

def execute
  body = {
    "query":       @query,
    "count":       @count,
    "batchSize":   @batchSize,
    "ttl":         @ttl,
    "cache":       @cache,
    "options":     @options,
    "bindVars":    @bindVars,
    "memoryLimit": @memoryLimit
  }
  result = @database.request("POST", "_api/cursor", body: body)
  return_aql(result)
end

#explainObject

PROPERTY QUERY ===



142
143
144
145
146
147
148
149
# File 'lib/AQL.rb', line 142

def explain
  body = {
    "query":    @query,
    "options":  @options,
    "bindVars": @bindVars
  }
  @database.request("POST", "_api/explain", body: body)
end

#killObject



136
137
138
# File 'lib/AQL.rb', line 136

def kill
  @database.request("DELETE", "_api/query/#{@id}")
end

#nextObject



123
124
125
126
127
128
129
130
# File 'lib/AQL.rb', line 123

def next
  if @hasMore
    result = @database.request("PUT", "_api/cursor/#{@id}")
    return_aql(result)
  else
    raise Arango::Error.new err::no_other_aql_next, data: {"hasMore": false}
  end
end

#parseObject



151
152
153
# File 'lib/AQL.rb', line 151

def parse
  @database.request("POST", "_api/query", body: {"query": @query})
end

#to_hObject

TO HASH ===



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/AQL.rb', line 68

def to_h
  {
    "query":       @query,
    "result":      @result,
    "count":       @count,
    "quantity":    @quantity,
    "ttl":         @ttl,
    "cache":       @cache,
    "batchSize":   @batchSize,
    "bindVars":    @bindVars,
    "options":     @options,
    "idCache":     @idCache,
    "memoryLimit": @memoryLimit,
    "database":    @database.name
  }.delete_if{|k,v| v.nil?}
end