Class: Arango::Database

Inherits:
Object
  • Object
show all
Includes:
AQLFunctions, AQLQueries, AQLQueryCache, Collections, DocumentCollections, EdgeCollections, FoxxServices, Graphs, HTTPRoute, Replication, StreamTransactions, Tasks, Transactions, ViewAccess, Helper::Satisfaction
Defined in:
lib/arango/database.rb,
lib/arango/database/user.rb,
lib/arango/database/tasks.rb,
lib/arango/database/graphs.rb,
lib/arango/database/analyzer.rb,
lib/arango/database/http_route.rb,
lib/arango/database/aql_queries.rb,
lib/arango/database/collections.rb,
lib/arango/database/replication.rb,
lib/arango/database/view_access.rb,
lib/arango/database/transactions.rb,
lib/arango/database/aql_functions.rb,
lib/arango/database/foxx_services.rb,
lib/arango/database/aql_query_cache.rb,
lib/arango/database/edge_collections.rb,
lib/arango/database/system_collections.rb,
lib/arango/database/stream_transactions.rb,
lib/arango/database/document_collections.rb

Overview

Arango Database

Defined Under Namespace

Modules: AQLFunctions, AQLQueries, AQLQueryCache, Analyzer, Collections, DocumentCollections, EdgeCollections, FoxxServices, Graphs, HTTPRoute, Replication, StreamTransactions, SystemCollections, Tasks, Transactions, User, ViewAccess

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ViewAccess

#create_search_view, #create_view, #list_views, #search_view, #view, #views

Methods included from Transactions

#transaction

Methods included from Tasks

#all_tasks, #create_task, #drop_task, #get_task, #list_tasks, #new_task, #task_exists?

Methods included from StreamTransactions

#abort_stream_transaction, #begin_stream_transaction, #commit_stream_transaction, #list_stream_transactions, #stream_transaction

Methods included from Replication

#cluster_inventory, #inventory, #last_tick, #logger, #logger_first_tick, #logger_follow, #logger_range_tick, #range, #replication, #replication_as_master, #server_id, #tail

Methods included from AQLQueryCache

#clear_query_cache, #get_query_cache, #query_cache_properties, #set_query_cache_properties

Methods included from AQLQueries

#batch_execute_aql, #batch_execute_query, #clear_slow_queries_list, #execute_aql, #execute_query, #kill_query, #new_aql, #new_query, #query_tracking_properties, #running_queries, #set_query_tracking_properties, #slow_queries

Methods included from HTTPRoute

#route

Methods included from Graphs

#all_graphs, #create_graph, #delete_graph, #get_graph, #graph_exists?, #list_graphs, #new_graph

Methods included from FoxxServices

#commit_local_Service_state, #disable_service_development_mode, #download_service, #enable_service_development_mode, #get_service, #get_service_configuration, #get_service_dependencies, #get_service_documentation, #get_service_readme, #install_service, #list_service_scripts, #list_services, #replace_service, #replace_service_configuration, #replace_service_dependencies, #run_service_script, #run_service_tests, #uninstall_service, #update_service_configuration, #update_service_dependencies, #upgrade_service

Methods included from EdgeCollections

#all_edge_collections, #create_edge_collection, #delete_edge_collection, #edge_collection_exists?, #get_edge_collection, #list_edge_collections, #new_edge_collection

Methods included from DocumentCollections

#all_document_collections, #batch_all_document_collections, #batch_create_document_collection, #batch_document_collection_exists?, #batch_drop_document_collection, #batch_get_document_collection, #batch_list_document_collections, #create_document_collection, #document_collection_exists?, #drop_document_collection, #get_document_collection, #list_document_collections, #new_document_collection

Methods included from Collections

#all_collections, #batch_all_collections, #batch_collection_exists?, #batch_create_collection, #batch_delete_collection, #batch_get_collection, #batch_list_collections, #collection_exists?, #create_collection, #delete_collection, #get_collection, #list_collections, #new_collection

Methods included from AQLFunctions

#create_aql_function, #drop_aql_function, #list_aql_functions

Methods included from Helper::Satisfaction

#satisfy_category?, #satisfy_class?, #satisfy_class_or_string?, #satisfy_module?, #satisfy_module_or_nil?, #satisfy_module_or_string?, #warning_deprecated

Constructor Details

#initialize(name:, id: nil, is_system: false, path: '', server: Arango.current_server) ⇒ Arango::Database

Instantiate a new database. All params except name and server are optional.

Parameters:

  • name (String)
  • server (Arango::Server) (defaults to: Arango.current_server)
  • id (defaults to: nil)
  • is_system (defaults to: false)
  • path (defaults to: '')


90
91
92
93
94
95
96
# File 'lib/arango/database.rb', line 90

def initialize(name:, id: nil, is_system: false, path: '', server: Arango.current_server)
  send(:server=, server)
  @name = name
  @is_system = is_system
  @path = path
  @id = id
end

Instance Attribute Details

#is_systemBoolean (readonly)

Whether or not the current database is the _system database

Returns:

  • (Boolean)


100
101
102
# File 'lib/arango/database.rb', line 100

def is_system
  @is_system
end

#nameString (readonly)

The name of the database

Returns:

  • (String)


104
105
106
# File 'lib/arango/database.rb', line 104

def name
  @name
end

#pathString (readonly)

The filesystem path of the current database

Returns:

  • (String)


108
109
110
# File 'lib/arango/database.rb', line 108

def path
  @path
end

#serverObject

Returns the value of attribute server.



110
111
112
# File 'lib/arango/database.rb', line 110

def server
  @server
end

Class Method Details

.all(server:) ⇒ Array<Arango::Database>

Retrieves all databases.

Parameters:

Returns:



27
28
29
# File 'lib/arango/database.rb', line 27

def all(server:)
  list(server: server).map{ |db| Arango::Database.new(name: db, server: server).reload }
end

.all_user_databases(server:) ⇒ Array<Arango::Database>

Retrieves all databases the current user can access.

Parameters:

Returns:



34
35
36
# File 'lib/arango/database.rb', line 34

def all_user_databases(server:)
  list_user_databases(server: server).map{ |db| Arango::Database.new(name: db, server: server).reload }
end

.createObject

Create a new instance of self



39
40
41
# File 'lib/arango/database.rb', line 39

def create()
  self.new.create
end

.delete(name:, server:) ⇒ Object

Removes a database.

Parameters:

Returns:

  • nil



69
70
71
72
# File 'lib/arango/database.rb', line 69

def delete(name:, server:)
  Arango::Requests::Database::Delete.execute(server: server, args: {name: name})
  nil
end

.exists?(name:, server:) ⇒ Boolean

Check if database exists.

Parameters:

Returns:

  • (Boolean)


78
79
80
# File 'lib/arango/database.rb', line 78

def exists?(name:, server:)
  list(server: server).include?(name)
end

.get(name:, server:) ⇒ Arango::Database

Get database from server.

Parameters:

Returns:



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

def get(name:, server:)
  Arango::Database.new(name: name, server: server).reload
end

.list(server:) ⇒ Array<String>

Retrieves a list of all databases.

Parameters:

Returns:

  • (Array<String>)

    List of database names.



54
55
56
# File 'lib/arango/database.rb', line 54

def list(server:)
  result = Arango::Requests::Database::ListAll.execute(server: server).result        
end

.list_user_databases(server:) ⇒ Array<String>

Retrieves a list of all databases the current user can access.

Parameters:

Returns:

  • (Array<String>)

    List of database names.



61
62
63
# File 'lib/arango/database.rb', line 61

def list_user_databases(server:)
  result = Arango::Requests::Database::ListAccessible.execute(server: server).result
end

Instance Method Details

#createArango::Database

Creates the database on the server.

Returns:



119
120
121
122
123
# File 'lib/arango/database.rb', line 119

def create
  # TODO users: users
  Arango::Requests::Database::Create.execute(server: self.server, body: { name: @name })
  self
end

#deleteObject

Remove database from the server.

Returns:

  • nil



135
136
137
138
# File 'lib/arango/database.rb', line 135

def delete
  self.class.delete(name: @name, server: @arango_server)
  nil
end

#driver_instanceObject

driver for database’s server



113
114
115
# File 'lib/arango/database.rb', line 113

def driver_instance
  @server.driver_instance
end

#reloadArango::Database

Reload database properties.

Returns:



127
128
129
130
131
# File 'lib/arango/database.rb', line 127

def reload
  result = Arango::Requests::Database::GetInformation.execute(server: self.server, args: { db: @name })
  _update_attributes(result)
  self
end

#target_versionString

Returns the database version that this server requires.

Returns:

  • (String)


142
143
144
# File 'lib/arango/database.rb', line 142

def target_version
  Arango::Requests::Administration::TargetVersion.execute(server: self.server).version
end