Details about the ArangoDB Shell

After the server has been started,you can use the ArangoDB shell (arangosh) to administrate theserver. Without any arguments, the ArangoDB shell will try to contactthe server on port 8529 on the localhost. For more information see theArangoDB Shell documentation. You might need to set additional options(endpoint, username and password) when connecting:

  1. unix> ./arangosh --server.endpoint tcp://127.0.0.1:8529 --server.username root

The shell will print its own version number and if successfully connectedto a server the version number of the ArangoDB server.

Command-Line Options

Use —help to get a list of command-line options:

  1. unix> ./arangosh --help
  2. STANDARD options:
  3. --audit-log <string> audit log file to save commands and results to
  4. --configuration <string> read configuration file
  5. --help help message
  6. --max-upload-size <uint64> maximum size of import chunks (in bytes) (default: 500000)
  7. --no-auto-complete disable auto completion
  8. --no-colors deactivate color support
  9. --pager <string> output pager (default: "less -X -R -F -L")
  10. --pretty-print pretty print values
  11. --quiet no banner
  12. --temp.path <string> path for temporary files (default: "/tmp/arangodb")
  13. --use-pager use pager
  14. JAVASCRIPT options:
  15. --javascript.check <string> syntax check code JavaScript code from file
  16. --javascript.execute <string> execute JavaScript code from file
  17. --javascript.execute-string <string> execute JavaScript code from string
  18. --javascript.startup-directory <string> startup paths containing the JavaScript files
  19. --javascript.unit-tests <string> do not start as shell, run unit tests instead
  20. --jslint <string> do not start as shell, run jslint instead
  21. LOGGING options:
  22. --log.level <string> log level (default: "info")
  23. CLIENT options:
  24. --server.connect-timeout <double> connect timeout in seconds (default: 3)
  25. --server.authentication <bool> whether or not to use authentication (default: true)
  26. --server.endpoint <string> endpoint to connect to, use 'none' to start without a server (default: "tcp://127.0.0.1:8529")
  27. --server.password <string> password to use when connecting (leave empty for prompt)
  28. --server.request-timeout <double> request timeout in seconds (default: 300)
  29. --server.username <string> username to use when connecting (default: "root")

Database Wrappers

The db object is available in arangosh_as well as on _arangod i.e. if you’re using Foxx. While itsinterface is persistent between the arangosh and the arangod implementations,its underpinning is not. The arangod implementation are JavaScript wrappersaround ArangoDB’s native C++ implementation, whereas the arangosh implementationwraps HTTP accesses to ArangoDB’s RESTfull API.

So while this code may produce similar results when executed in arangosh andarangod, the cpu usage and time required will be really different:

  1. for (i = 0; i < 100000; i++) {
  2. db.test.save({ name: { first: "Jan" }, count: i});
  3. }

Since the arangosh version will be doing around 100k HTTP requests, and thearangod version will directly write to the database.

Using arangosh via unix shebang mechanisms

In unix operating systems you can start scripts by specifying the interpreter in the first line of the script.This is commonly called shebang or hash bang. You can also do that with arangosh, i.e. create ~/test.js:

  1. #!/usr/bin/arangosh --javascript.execute
  2. require("internal").print("hello world")
  3. db._query("FOR x IN test RETURN x").toArray()

Note that the first line has to end with a blank in order to make it work.Mark it executable to the OS:

  1. #> chmod a+x ~/test.js

and finaly try it out:

  1. #> ~/test.js