Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Add documentation about options used in database creation #243

Merged
merged 5 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 3.5/appendix-references-dbobject.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following methods exists on the *_db* object:
* [db._isSystem()](data-modeling-databases-working-with.html#issystem)
* [db._name()](data-modeling-databases-working-with.html#name)
* [db._path()](data-modeling-databases-working-with.html#path)
* [db._version()](data-modeling-documents-document-methods.html#get-the-version-of-arangodb)
* [db._queryProperties()](data-modeling-databases-working-with.html#properties)

*Collection*

Expand Down Expand Up @@ -67,3 +67,4 @@ The following methods exists on the *_db* object:
* [db._engine()](data-modeling-databases-working-with.html#engine)
* [db._engineStats()](data-modeling-databases-working-with.html#engine-statistics)
* [db._executeTransaction()](transactions-transaction-invocation.html)
* [db._version()](data-modeling-databases-working-with.html#get-the-version-of-arangodb)
46 changes: 45 additions & 1 deletion 3.5/data-modeling-databases-working-with.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ database management operations such as create or drop can only be executed
from within this database. Additionally, the *_system* database itself
cannot be dropped.

### Properties

<!-- arangod/V8Server/v8-vocbase.cpp -->

return the path to database files
`db._queryProperties()`

Returns the properties of the current database as an object with the following
attributes:

- *id*: the database id
- *name*: the database name
- *isSystem*: the database type
- *path*: the path to database files

**Examples**

{% arangoshexample examplevar="examplevar" script="script" result="result" %}
@startDocuBlockInline dbProperties
@EXAMPLE_ARANGOSH_OUTPUT{dbProperties}
require("@arangodb").db._queryProperties();
@END_EXAMPLE_ARANGOSH_OUTPUT
@endDocuBlock dbProperties
{% endarangoshexample %}
{% include arangoshexample.html id=examplevar script=script result=result %}

### Use Database
<!-- arangod/V8Server/v8-vocbase.cpp -->
Expand Down Expand Up @@ -203,10 +228,29 @@ as a list of supported features (types of indexes and

### Engine statistics

retrieve statistics related to the storage engine (rocksdb)
retrieve statistics related to the storage engine (RocksDB)
`db._engineStats()`

Returns some statistics related to the storage engine activity, including figures
about data size, cache usage, etc.

**Note**: Currently this only produces useful output for the RocksDB engine.

Get the Version of ArangoDB
---------------------------

`db._version()`

Returns the server version string. Note that this is not the version of the
database.

**Examples**

{% arangoshexample examplevar="examplevar" script="script" result="result" %}
@startDocuBlockInline dbVersion
@EXAMPLE_ARANGOSH_OUTPUT{dbVersion}
require("@arangodb").db._version();
@END_EXAMPLE_ARANGOSH_OUTPUT
@endDocuBlock dbVersion
{% endarangoshexample %}
{% include arangoshexample.html id=examplevar script=script result=result %}
19 changes: 0 additions & 19 deletions 3.5/data-modeling-documents-document-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -1255,25 +1255,6 @@ Throws if the document key is invalid. Note that this method does not
check whether the document already exists in this collection.


Get the Version of ArangoDB
---------------------------

`db._version()`

Returns the server version string. Note that this is not the version of the
database.


**Examples**
{% arangoshexample examplevar="examplevar" script="script" result="result" %}

@startDocuBlockInline dbVersion
@EXAMPLE_ARANGOSH_OUTPUT{dbVersion}
require("@arangodb").db._version();
@END_EXAMPLE_ARANGOSH_OUTPUT
@endDocuBlock dbVersion
{% endarangoshexample %}
{% include arangoshexample.html id=examplevar script=script result=result %}
Edges
-----

Expand Down
3 changes: 2 additions & 1 deletion 3.6/appendix-references-dbobject.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following methods exists on the *_db* object:
* [db._isSystem()](data-modeling-databases-working-with.html#issystem)
* [db._name()](data-modeling-databases-working-with.html#name)
* [db._path()](data-modeling-databases-working-with.html#path)
* [db._version()](data-modeling-documents-document-methods.html#get-the-version-of-arangodb)
* [db._properties()](data-modeling-databases-working-with.html#properties)

*Collection*

Expand Down Expand Up @@ -67,3 +67,4 @@ The following methods exists on the *_db* object:
* [db._engine()](data-modeling-databases-working-with.html#engine)
* [db._engineStats()](data-modeling-databases-working-with.html#engine-statistics)
* [db._executeTransaction()](transactions-transaction-invocation.html)
* [db._version()](data-modeling-databases-working-with.html#get-the-version-of-arangodb)
109 changes: 81 additions & 28 deletions 3.6/data-modeling-databases-working-with.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ Please note that several of these methods can be used from the _system
database only.

### Name
<!-- arangod/V8Server/v8-vocbase.cpp -->

<!-- arangod/V8Server/v8-vocbase.cpp -->

return the database name
`db._name()`

Returns the name of the current database as a string.


**Examples**
{% arangoshexample examplevar="examplevar" script="script" result="result" %}

{% arangoshexample examplevar="examplevar" script="script" result="result" %}
@startDocuBlockInline dbName
@EXAMPLE_ARANGOSH_OUTPUT{dbName}
require("@arangodb").db._name();
Expand All @@ -34,18 +33,17 @@ Returns the name of the current database as a string.
{% include arangoshexample.html id=examplevar script=script result=result %}

### ID
<!-- arangod/V8Server/v8-vocbase.cpp -->

<!-- arangod/V8Server/v8-vocbase.cpp -->

return the database id
`db._id()`

Returns the id of the current database as a string.


**Examples**
{% arangoshexample examplevar="examplevar" script="script" result="result" %}

{% arangoshexample examplevar="examplevar" script="script" result="result" %}
@startDocuBlockInline dbId
@EXAMPLE_ARANGOSH_OUTPUT{dbId}
require("@arangodb").db._id();
Expand All @@ -55,18 +53,17 @@ Returns the id of the current database as a string.
{% include arangoshexample.html id=examplevar script=script result=result %}

### Path
<!-- arangod/V8Server/v8-vocbase.cpp -->

<!-- arangod/V8Server/v8-vocbase.cpp -->

return the path to database files
`db._path()`

Returns the filesystem path of the current database as a string.


**Examples**
{% arangoshexample examplevar="examplevar" script="script" result="result" %}

{% arangoshexample examplevar="examplevar" script="script" result="result" %}
@startDocuBlockInline dbPath
@EXAMPLE_ARANGOSH_OUTPUT{dbPath}
require("@arangodb").db._path();
Expand All @@ -76,8 +73,8 @@ Returns the filesystem path of the current database as a string.
{% include arangoshexample.html id=examplevar script=script result=result %}

### isSystem
<!-- arangod/V8Server/v8-vocbase.cpp -->

<!-- arangod/V8Server/v8-vocbase.cpp -->

return the database type
`db._isSystem()`
Expand All @@ -88,10 +85,40 @@ database management operations such as create or drop can only be executed
from within this database. Additionally, the *_system* database itself
cannot be dropped.

### Properties

### Use Database
<!-- arangod/V8Server/v8-vocbase.cpp -->

return the path to database files
`db._properties()`

Returns the properties of the current database as an object with the following
attributes:

- *id*: the database id
- *name*: the database name
- *isSystem*: the database type
- *path*: the path to database files
- *sharding*: the sharding method to use for new collections *(Cluster only)*
- *replicationFactor*: default replication factor for new collections
*(Cluster only)*
- *writeConcern*: a shard will refuse to write if less than this amount
of copies are in sync *(Cluster only)*

**Examples**

{% arangoshexample examplevar="examplevar" script="script" result="result" %}
@startDocuBlockInline dbProperties_cluster
@EXAMPLE_ARANGOSH_OUTPUT{dbProperties_cluster}
require("@arangodb").db._properties();
@END_EXAMPLE_ARANGOSH_OUTPUT
@endDocuBlock dbProperties_cluster
{% endarangoshexample %}
{% include arangoshexample.html id=examplevar script=script result=result %}

### Use Database

<!-- arangod/V8Server/v8-vocbase.cpp -->

change the current database
`db._useDatabase(name)`
Expand All @@ -110,21 +137,19 @@ database might not work, and the connection / session should be closed and
restarted with different username and password credentials and/or
endpoint data.


### List Databases
<!-- arangod/V8Server/v8-vocbase.cpp -->

<!-- arangod/V8Server/v8-vocbase.cpp -->

return the list of all existing databases
`db._databases()`

Returns the list of all databases. This method can only be used from within
the *_system* database.


### Create Database
<!-- arangod/V8Server/v8-vocbase.cpp -->

<!-- arangod/V8Server/v8-vocbase.cpp -->

create a new database
`db._createDatabase(name, options, users)`
Expand All @@ -138,19 +163,29 @@ change into the current database to the new database. Changing the current
database must explicitly be requested by using the
*db._useDatabase* method.

The *options* attribute currently has no meaning and is reserved for
future use.
The *options* attribute can be used to set defaults for collections that will
be created in the new database:

- *sharding*: The sharding method to use. Valid values are: `""` or `"single"`.
Setting this option to `"single"` will enable the OneShard feature in the
Enterprise Edition.
- *replicationFactor*: Default replication factor. Special values include
`"satellite"`, which will replicate the collection to every DBServer, and
`1`, which disables replication.
- *minReplicationFactor*: Default minimum replication factor. If there are
less than minReplication replicas available the collection will become
read-only.

The optional *users* attribute can be used to create initial users for
the new database. If specified, it must be a list of user objects. Each user
object can contain the following attributes:

* *username*: the user name as a string. This attribute is mandatory.
* *passwd*: the user password as a string. If not specified, then it defaults
- *username*: the user name as a string. This attribute is mandatory.
- *passwd*: the user password as a string. If not specified, then it defaults
to an empty string.
* *active*: a boolean flag indicating whether the user account should be
- *active*: a boolean flag indicating whether the user account should be
active or not. The default value is *true*.
* *extra*: an optional JSON object with extra user information. The data
- *extra*: an optional JSON object with extra user information. The data
contained in *extra* will be stored for the user but not be interpreted
further by ArangoDB.

Expand All @@ -163,22 +198,21 @@ into the new database (username and password must be identical to the current
session) and add or modify users with the following commands.

```js
require("@arangodb/users").save(username, password, true);
require("@arangodb/users").update(username, password, true);
require("@arangodb/users").remove(username);
require("@arangodb/users").save(username, password, true);
require("@arangodb/users").update(username, password, true);
require("@arangodb/users").remove(username);
```
Alternatively, you can specify user data directly. For example:

```js
db._createDatabase("newDB", {}, [{ username: "newUser", passwd: "123456", active: true}])
db._createDatabase("newDB", {}, [{ username: "newUser", passwd: "123456", active: true}])
```

Those methods can only be used from within the *_system* database.


### Drop Database
<!-- arangod/V8Server/v8-vocbase.cpp -->

<!-- arangod/V8Server/v8-vocbase.cpp -->

drop an existing database
`db._dropDatabase(name)`
Expand All @@ -203,10 +237,29 @@ as a list of supported features (types of indexes and

### Engine statistics

retrieve statistics related to the storage engine (rocksdb)
retrieve statistics related to the storage engine (RocksDB)
`db._engineStats()`

Returns some statistics related to the storage engine activity, including figures
about data size, cache usage, etc.

**Note**: Currently this only produces useful output for the RocksDB engine.

Get the Version of ArangoDB
---------------------------

`db._version()`

Returns the server version string. Note that this is not the version of the
database.

**Examples**

{% arangoshexample examplevar="examplevar" script="script" result="result" %}
@startDocuBlockInline dbVersion
@EXAMPLE_ARANGOSH_OUTPUT{dbVersion}
require("@arangodb").db._version();
@END_EXAMPLE_ARANGOSH_OUTPUT
@endDocuBlock dbVersion
{% endarangoshexample %}
{% include arangoshexample.html id=examplevar script=script result=result %}
19 changes: 0 additions & 19 deletions 3.6/data-modeling-documents-document-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -1255,25 +1255,6 @@ Throws if the document key is invalid. Note that this method does not
check whether the document already exists in this collection.


Get the Version of ArangoDB
---------------------------

`db._version()`

Returns the server version string. Note that this is not the version of the
database.


**Examples**
{% arangoshexample examplevar="examplevar" script="script" result="result" %}

@startDocuBlockInline dbVersion
@EXAMPLE_ARANGOSH_OUTPUT{dbVersion}
require("@arangodb").db._version();
@END_EXAMPLE_ARANGOSH_OUTPUT
@endDocuBlock dbVersion
{% endarangoshexample %}
{% include arangoshexample.html id=examplevar script=script result=result %}
Edges
-----

Expand Down