Handling Databases

This is an introduction to managing databases in ArangoDB from within JavaScript.

When you have an established connection to ArangoDB, the currentdatabase can be changed explicitly using the _db._useDatabase()_method. This will switch to the specified database (provided itexists and the user can connect to it). From this point on, anyfollowing action in the same shell or connection will use thespecified database, unless otherwise specified.

Note: If the database is changed, client drivers need to store the current database name on their side, too. This is because connectionsin ArangoDB do not contain any state information. All state informationis contained in the HTTP request/response data.

To connect to a specific database after arangosh has started use the commanddescribed above. It is also possible to specify a database name when invokingarangosh. For this purpose, use the command-line parameter —server.database,e.g.

  1. > arangosh --server.database test

Please note that commands, actions, scripts or AQL queries should neveraccess multiple databases, even if they exist. The only intended andsupported way in ArangoDB is to use one database at a time for a command,an action, a script or a query. Operations started in one database mustnot switch the database later and continue operating in another.