2

Our production environment doesn't provide a shell but only javascript engine and REST interface. Our arangodb server will be installed at a remote location. Since all of our users are comfortable with javascript implementation we are looking for a solution if we could provide them an interface where they write the queries for arangodb in javascript (the way we do in arangodbsh) and we can execute them remotely and get the result. Is it somehow possible ?

I am new to arangodb and so far I have found that there is only REST interface available to interact remotely.

arangosh is not available and can not be used.

Deepak Agarwal
  • 907
  • 6
  • 21

1 Answers1

4

You can use arangosh to connect to the remote server as it uses the REST interface to work. All information on connecting to your server is available via arangosh --help. The default behaviour of arangosh is to connect to a local ArangoDB instance, but it can connect to remote ones as well.

You probably want to do something like, where 1.2.3.4 is the IP of your remote server:

arangosh --server.endpoint tcp://1.2.3.4:8529

If you want to execute arbitrary JavaScript code in ArangoDB from an application, you can use the endpoint /_admin/execute described here that takes JavaScript code as its body that will be executed in ArangoDB. Be aware that this is a potential security risk

moonglum
  • 801
  • 5
  • 13
  • Shell is not available to the environment I want to run javascript from :( . The environment is a cloud where javascript engine and REST is available but no shell. – Deepak Agarwal Nov 18 '14 at 10:45
  • @DeepakAgarwal You can run arangosh on your local machine. It doesn't need to be available on the server :) – moonglum Nov 18 '14 at 12:11
  • :) Yea. Actually let me explain more. My application resides on a cloud platform (ServiceNow). I can not install arango there. Arangodb is installed at separate machine. Users of my application can write only javascript and REST calls (which are residing at servicenow only). So I need a way where the written javascripts can be run at Arangodb from my servicenow application. So, scripts are essentially remote. One way is to use AQL but our scripts would be complex. arangosh can not be available at servicenow app at all. – Deepak Agarwal Nov 18 '14 at 12:13
  • 1
    Ok, understood. Adjusted the answer above! Hope that helps? Please be aware of the security implications of this step. – moonglum Nov 18 '14 at 12:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/65147/discussion-between-deepak-agarwal-and-moonglum). – Deepak Agarwal Nov 18 '14 at 13:10
  • One last thing. could u plz point me to an example. Because when I try executing it with "return db.events.properties;" I get this exception: JavaScript exception in file 'undefined' at 1,21: ReferenceError: db is not defined !(function() {return db.events.properties; ! ^ stacktrace: ReferenceError: db is not defined at eval (:1:21) at Function.eval (:2:2) at Function.actions.defineHttp.callback (C:\Program Files\ArangoDB 2.2.6\share\arangodb\js\actions\api-system.js:1009:16) – Deepak Agarwal Nov 18 '14 at 15:25