@@ -13,18 +13,17 @@ Please note that several of these methods can be used from the _system
13
13
database only.
14
14
15
15
### Name
16
- <!-- arangod/V8Server/v8-vocbase.cpp -->
17
16
17
+ <!-- arangod/V8Server/v8-vocbase.cpp -->
18
18
19
19
return the database name
20
20
` db._name() `
21
21
22
22
Returns the name of the current database as a string.
23
23
24
-
25
24
** Examples**
26
- {% arangoshexample examplevar="examplevar" script="script" result="result" %}
27
25
26
+ {% arangoshexample examplevar="examplevar" script="script" result="result" %}
28
27
@startDocuBlockInline dbName
29
28
@EXAMPLE_ARANGOSH_OUTPUT{dbName}
30
29
require("@arangodb ").db._ name();
@@ -34,18 +33,17 @@ Returns the name of the current database as a string.
34
33
{% include arangoshexample.html id=examplevar script=script result=result %}
35
34
36
35
### ID
37
- <!-- arangod/V8Server/v8-vocbase.cpp -->
38
36
37
+ <!-- arangod/V8Server/v8-vocbase.cpp -->
39
38
40
39
return the database id
41
40
` db._id() `
42
41
43
42
Returns the id of the current database as a string.
44
43
45
-
46
44
** Examples**
47
- {% arangoshexample examplevar="examplevar" script="script" result="result" %}
48
45
46
+ {% arangoshexample examplevar="examplevar" script="script" result="result" %}
49
47
@startDocuBlockInline dbId
50
48
@EXAMPLE_ARANGOSH_OUTPUT{dbId}
51
49
require("@arangodb ").db._ id();
@@ -55,18 +53,17 @@ Returns the id of the current database as a string.
55
53
{% include arangoshexample.html id=examplevar script=script result=result %}
56
54
57
55
### Path
58
- <!-- arangod/V8Server/v8-vocbase.cpp -->
59
56
57
+ <!-- arangod/V8Server/v8-vocbase.cpp -->
60
58
61
59
return the path to database files
62
60
` db._path() `
63
61
64
62
Returns the filesystem path of the current database as a string.
65
63
66
-
67
64
** Examples**
68
- {% arangoshexample examplevar="examplevar" script="script" result="result" %}
69
65
66
+ {% arangoshexample examplevar="examplevar" script="script" result="result" %}
70
67
@startDocuBlockInline dbPath
71
68
@EXAMPLE_ARANGOSH_OUTPUT{dbPath}
72
69
require("@arangodb ").db._ path();
@@ -76,8 +73,8 @@ Returns the filesystem path of the current database as a string.
76
73
{% include arangoshexample.html id=examplevar script=script result=result %}
77
74
78
75
### isSystem
79
- <!-- arangod/V8Server/v8-vocbase.cpp -->
80
76
77
+ <!-- arangod/V8Server/v8-vocbase.cpp -->
81
78
82
79
return the database type
83
80
` db._isSystem() `
@@ -88,10 +85,40 @@ database management operations such as create or drop can only be executed
88
85
from within this database. Additionally, the * _ system* database itself
89
86
cannot be dropped.
90
87
88
+ ### Properties
91
89
92
- ### Use Database
93
90
<!-- arangod/V8Server/v8-vocbase.cpp -->
94
91
92
+ return the path to database files
93
+ ` db._properties() `
94
+
95
+ Returns the properties of the current database as an object with the following
96
+ attributes:
97
+
98
+ - * id* : the database id
99
+ - * name* : the database name
100
+ - * isSystem* : the database type
101
+ - * path* : the path to database files
102
+ - * sharding* : the sharding method to use for new collections * (Cluster only)*
103
+ - * replicationFactor* : default replication factor for new collections
104
+ * (Cluster only)*
105
+ - * writeConcern* : a shard will refuse to write if less than this amount
106
+ of copies are in sync * (Cluster only)*
107
+
108
+ ** Examples**
109
+
110
+ {% arangoshexample examplevar="examplevar" script="script" result="result" %}
111
+ @startDocuBlockInline dbProperties_cluster
112
+ @EXAMPLE_ARANGOSH_OUTPUT{dbProperties_cluster}
113
+ require("@arangodb ").db._ properties();
114
+ @END_EXAMPLE_ARANGOSH_OUTPUT
115
+ @endDocuBlock dbProperties_cluster
116
+ {% endarangoshexample %}
117
+ {% include arangoshexample.html id=examplevar script=script result=result %}
118
+
119
+ ### Use Database
120
+
121
+ <!-- arangod/V8Server/v8-vocbase.cpp -->
95
122
96
123
change the current database
97
124
` db._useDatabase(name) `
@@ -110,21 +137,19 @@ database might not work, and the connection / session should be closed and
110
137
restarted with different username and password credentials and/or
111
138
endpoint data.
112
139
113
-
114
140
### List Databases
115
- <!-- arangod/V8Server/v8-vocbase.cpp -->
116
141
142
+ <!-- arangod/V8Server/v8-vocbase.cpp -->
117
143
118
144
return the list of all existing databases
119
145
` db._databases() `
120
146
121
147
Returns the list of all databases. This method can only be used from within
122
148
the * _ system* database.
123
149
124
-
125
150
### Create Database
126
- <!-- arangod/V8Server/v8-vocbase.cpp -->
127
151
152
+ <!-- arangod/V8Server/v8-vocbase.cpp -->
128
153
129
154
create a new database
130
155
` db._createDatabase(name, options, users) `
@@ -138,19 +163,29 @@ change into the current database to the new database. Changing the current
138
163
database must explicitly be requested by using the
139
164
* db._ useDatabase* method.
140
165
141
- The * options* attribute currently has no meaning and is reserved for
142
- future use.
166
+ The * options* attribute can be used to set defaults for collections that will
167
+ be created in the new database:
168
+
169
+ - * sharding* : The sharding method to use. Valid values are: ` "" ` or ` "single" ` .
170
+ Setting this option to ` "single" ` will enable the OneShard feature in the
171
+ Enterprise Edition.
172
+ - * replicationFactor* : Default replication factor. Special values include
173
+ ` "satellite" ` , which will replicate the collection to every DBServer, and
174
+ ` 1 ` , which disables replication.
175
+ - * minReplicationFactor* : Default minimum replication factor. If there are
176
+ less than minReplication replicas available the collection will become
177
+ read-only.
143
178
144
179
The optional * users* attribute can be used to create initial users for
145
180
the new database. If specified, it must be a list of user objects. Each user
146
181
object can contain the following attributes:
147
182
148
- * * username* : the user name as a string. This attribute is mandatory.
149
- * * passwd* : the user password as a string. If not specified, then it defaults
183
+ - * username* : the user name as a string. This attribute is mandatory.
184
+ - * passwd* : the user password as a string. If not specified, then it defaults
150
185
to an empty string.
151
- * * active* : a boolean flag indicating whether the user account should be
186
+ - * active* : a boolean flag indicating whether the user account should be
152
187
active or not. The default value is * true* .
153
- * * extra* : an optional JSON object with extra user information. The data
188
+ - * extra* : an optional JSON object with extra user information. The data
154
189
contained in * extra* will be stored for the user but not be interpreted
155
190
further by ArangoDB.
156
191
@@ -163,22 +198,21 @@ into the new database (username and password must be identical to the current
163
198
session) and add or modify users with the following commands.
164
199
165
200
``` js
166
- require (" @arangodb/users" ).save (username, password, true );
167
- require (" @arangodb/users" ).update (username, password, true );
168
- require (" @arangodb/users" ).remove (username);
201
+ require (" @arangodb/users" ).save (username, password, true );
202
+ require (" @arangodb/users" ).update (username, password, true );
203
+ require (" @arangodb/users" ).remove (username);
169
204
```
170
205
Alternatively, you can specify user data directly. For example:
171
206
172
207
``` js
173
- db ._createDatabase (" newDB" , {}, [{ username: " newUser" , passwd: " 123456" , active: true }])
208
+ db ._createDatabase (" newDB" , {}, [{ username: " newUser" , passwd: " 123456" , active: true }])
174
209
```
175
210
176
211
Those methods can only be used from within the * _ system* database.
177
212
178
-
179
213
### Drop Database
180
- <!-- arangod/V8Server/v8-vocbase.cpp -->
181
214
215
+ <!-- arangod/V8Server/v8-vocbase.cpp -->
182
216
183
217
drop an existing database
184
218
` db._dropDatabase(name) `
@@ -203,10 +237,29 @@ as a list of supported features (types of indexes and
203
237
204
238
### Engine statistics
205
239
206
- retrieve statistics related to the storage engine (rocksdb )
240
+ retrieve statistics related to the storage engine (RocksDB )
207
241
` db._engineStats() `
208
242
209
243
Returns some statistics related to the storage engine activity, including figures
210
244
about data size, cache usage, etc.
211
245
212
246
** Note** : Currently this only produces useful output for the RocksDB engine.
247
+
248
+ Get the Version of ArangoDB
249
+ ---------------------------
250
+
251
+ ` db._version() `
252
+
253
+ Returns the server version string. Note that this is not the version of the
254
+ database.
255
+
256
+ ** Examples**
257
+
258
+ {% arangoshexample examplevar="examplevar" script="script" result="result" %}
259
+ @startDocuBlockInline dbVersion
260
+ @EXAMPLE_ARANGOSH_OUTPUT{dbVersion}
261
+ require("@arangodb ").db._ version();
262
+ @END_EXAMPLE_ARANGOSH_OUTPUT
263
+ @endDocuBlock dbVersion
264
+ {% endarangoshexample %}
265
+ {% include arangoshexample.html id=examplevar script=script result=result %}
0 commit comments