Some questions of a very novice person

171 views
Skip to first unread message

Andrés Orencio Ramírez Pérez

unread,
May 22, 2013, 11:27:42 AM5/22/13
to aran...@googlegroups.com
Hello, I recently learned about ArangoDB and I'd like to know some things to make a virtual shop example.

I've read "ArangoDB's User Manual (1.3.0)".
Apparently ArangoDB is changing to use Foxx to build applications, but in this moments it is not desirable.

So:
  1. Is it possible/desirable to use Foxx to build an application in this moment?
    When I try to use it (to make an example), I get this error:

    arangosh> var miAplicacion = require("org/arangodb/foxx").Application;
    JavaScript exception in file 'common/bootstrap/modules.js' at 880,54: cannot locate module 'org/arangodb/foxx' for package '/' using module path '/usr/share/arangodb/js/client/modules,/usr/share/arangodb/js/common/modules,/usr/share/arangodb/js/node' and package path '/usr/share/arangodb/js/npm'
    !      + " and package path '" + this._package._paths + "'";
    !
  2. In the manual it is commented that you must stablish routes to make usable the controller and functions. These routes are made through db._routing.save(...);, but these routes aren't dependent from the application you are making. If you are making the manual application example:

    arangosh> var deploy = require("org/arangodb/deploy");
    arangosh> var app = deploy.createApp("org.example.simple");

    there is an app._routing that appears to be the same like db._routing, so it isn't possible to encapsulate this app routing.
  3. If you create the application (of the step 2), and go to http://localhost:8529/_admin/html/index.html#applications/available, this application it isn't there. Why? It is not the way to make an application?
  4. In the appear a comment about arangodep, but says that arangosh has a deployment tool inspired on arangodep, so I think I mustn't use arangodep and I must use arangosh deployment tool, but what is this tool? app.mountStaticContent, app.mountStaticContent, app.setPrefix, ...? Where are these tools documented? Is it good idea use arangodep?
  5. What is db_aal?
  6. Is it possible to use some frameworks like Angularjs or KnockOutjs? Specially for databinding and separate view from model/controller.
  7. Is it possible to use local filesystem to store deployment files/source/configurations and clone/upload/update it to arangodb?
Thanks and excuse me for all this questions.


Andrés Orencio Ramírez Pérez

unread,
May 22, 2013, 11:55:17 AM5/22/13
to aran...@googlegroups.com
  1. When I try to use it (to make an example), I get this error:

    arangosh> var miAplicacion = require("org/arangodb/foxx").Application;
    JavaScript exception in file 'common/bootstrap/modules.js' at 880,54: cannot locate module 'org/arangodb/foxx' for package '/' using module path '/usr/share/arangodb/js/client/modules,/usr/share/arangodb/js/common/modules,/usr/share/arangodb/js/node' and package path '/usr/share/arangodb/js/npm'
    !      + " and package path '" + this._package._paths + "'";
    !

I've solved it modifying modules-path in /etc/arangodb/arangosh.conf by:

modules-path = /usr/share/arangodb/js/client/modules;/usr/share/arangodb/js/common/modules;/usr/share/arangodb/js/node;/usr/share/arangodb/js/server/modules;/usr/share/arangodb/js/common/modules;/usr/share/arangodb/js/node

Is this correct?

Jan Steemann

unread,
May 22, 2013, 1:37:11 PM5/22/13
to aran...@googlegroups.com, Andrés Orencio Ramírez Pérez
Hi Andrés,

AFAIK the Foxx applications are supposed to run on the server side,
whereas arangosh is "just" the client side. So the Foxx objects should
not be used inside arangosh directly.


The prefered way is that you create all the code for the Foxx
applications on the server side, at some point of your choice in the
file system.


Here are some steps that should work for you too:

When you start the arangod server, you should specify the
"--javascript.dev-app-path". This is more convenient for development
because you just need one server start, and the server will always pick
up changes in the application source files. This has a performance
penalty and can be turned off for production, but is convenient for
development.

I start my server like this:
bin/arangod data/ --javascript.dev-app-path /tmp/foxx

Of course the directory /tmp/foxx needs to be there. This is the
directory where you can put in the source code of your Foxx application.

My /tmp/foxx directory looks like this:

└── myapp
├── manifest.json
└── test.js

So I am having an app that's named "myapp". The manifest.json file in
/tmp/foxx/myapp/ looks like this:

{
"name": "my test app",
"version": "0.0.1",
"description": "whatever",

"apps": {
"/": "test.js"
}
}

Finally, the test.js file in /tmp/foxx/myapp/ has this content:

(function() {
"use strict";

var FoxxApplication = require("org/arangodb/foxx").Application,
app = new FoxxApplication();

app.get('/test', function (req, res) {
res.json("hello!");
});

// Remember to give the applicationContext.
app.start(applicationContext);
}());


If you put the files at the above locations (feel free to change the
paths if you prefer) you only need to register the app once, and then
should be able to use it afterwards.

Registering the app can be done in arangosh using the "aal" (arango
application loader) object like so:

require("org/arangodb/aal").installDevApp("myapp", "/myapp");

After that, you should be able to direct your browser to
http://localhost:8529/myapp/test

and see the output "hello!".
If you do any code changes to the test.js file, they should be picked up
immediately by the server in development mode.


I hope this answers a few questions already.
We'll look into the other questions soon, too.

Best regards
Jan


Am 22.05.2013 17:55, schrieb Andrés Orencio Ramírez Pérez:
> 1. When I try to use it (to make an example), I get this error:
> --
> You received this message because you are subscribed to the Google
> Groups "ArangoDB" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to arangodb+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Andrés Orencio Ramírez Pérez

unread,
May 22, 2013, 4:33:16 PM5/22/13
to aran...@googlegroups.com, Andrés Orencio Ramírez Pérez, j.ste...@triagens.de
Hello Jan and thank you for you rapid response.

I've probe your code and it runs :-))))
Only one little thing. Instead of calling arangod with parameter --javascript.dev-app-path, I've put it on /etc/arangodb/arangod.conf in [javascript] section.

Then I have modified the application with this:

test.js:
(function() {
  "use strict";

  var FoxxApplication = require("org/arangodb/foxx").Application,
  app = new FoxxApplication();

  app.registerRepository(
      "lib",
      {
          repository: "repositories/lib"
      }
  );

  app.get('/test', function (req, res) {
    res.json(repositories.lib.prueba());
  });

  // Remember to give the applicationContext.
  app.start(applicationContext);
}());

repositories/lib.js:
function prueba() {
    return "hola";
}

Foxx = require("org/arangodb/foxx");
rep = Foxx.Repository.extend({
        prueba: prueba
});

I want to create a lib modules and use them on arangodb server-side.

When I run it, I recieve this message (in /var/log/arangodb/arangod.log):
2013-05-22T20:32:16Z [4973] ERROR cannot install route '[object Object]': cannot locate module 'repositories/lib' for package 'application' using module path '/usr/share/arangodb/js/server/modules,/usr/share/arangodb/js/common/modules,/usr/share/arangodb/js/node' and package path '/home/aoramire/Desarrollo/arangodb/test/lib'
2013-05-22T20:32:17Z [4973] ERROR cannot install route '[object Object]': cannot locate module 'repositories/lib' for package 'application' using module path '/usr/share/arangodb/js/server/modules,/usr/share/arangodb/js/common/modules,/usr/share/arangodb/js/node' and package path '/home/aoramire/Desarrollo/arangodb/test/lib'

What I am doing bad?

Thanks.

Jan Steemann

unread,
May 22, 2013, 5:12:33 PM5/22/13
to aran...@googlegroups.com, Andrés Orencio Ramírez Pérez
Hola,

it's fine to put the --javascript.dev-app-path into the config file
instead of specifying it on the command line.

I think you were almost there with your test application.
Just the following line was missing in the "manifest.json" file
(specifying some path):

"lib" : "."

I am attaching my minimal working version as a tgz file for reference.

Best regards
Jan


Am 22.05.2013 22:33, schrieb Andrés Orencio Ramírez Pérez:
> Hello Jan and thank you for you rapid response.
>
>
> I've probe your code and it runs :-))))
> Only one little thing. Instead of calling arangod with parameter
> --javascript.dev-app-path, I've put it on /etc/arangodb/arangod.conf in
> [javascript] section.
>
> Then I have modified the application with this:
>
> *test.js*:
>
> (function() {
> "use strict";
>
> var FoxxApplication = require("org/arangodb/foxx").Application,
> app = new FoxxApplication();
>
> *app.registerRepository(*
> * "lib",*
> * {*
> * repository: "repositories/lib"*
> * }*
> * );*
>
> app.get('/test', function (req, res) {
> res.json(*repositories.lib.prueba()*);
> });
>
> // Remember to give the applicationContext.
> app.start(applicationContext);
> }());
>
>
> *repositories/lib.js*:
>
> function prueba() {
> return "hola";
> }
>
> Foxx = require("org/arangodb/foxx");
> rep = Foxx.Repository.extend({
> prueba: prueba
> });
>
>
> I want to create a lib modules and use them on arangodb server-side.
>
> When I run it, I recieve this message (in /var/log/arangodb/arangod.log):
>
> 2013-05-22T20:32:16Z [4973] ERROR cannot install route '[object
> Object]': cannot locate module 'repositories/lib' for package
> 'application' using module path
> '/usr/share/arangodb/js/server/modules,/usr/share/arangodb/js/common/modules,/usr/share/arangodb/js/node'
> and package path '/home/aoramire/Desarrollo/arangodb/test/lib'
> 2013-05-22T20:32:17Z [4973] ERROR cannot install route '[object
> Object]': cannot locate module 'repositories/lib' for package
> 'application' using module path
> '/usr/share/arangodb/js/server/modules,/usr/share/arangodb/js/common/modules,/usr/share/arangodb/js/node'
> and package path '/home/aoramire/Desarrollo/arangodb/test/lib'
>
>
> What I am doing bad?
>
> Thanks.
>
myapp.tgz

Andrés Orencio Ramírez Pérez

unread,
May 22, 2013, 5:51:48 PM5/22/13
to aran...@googlegroups.com, Andrés Orencio Ramírez Pérez, j.ste...@triagens.de
Hola :-)

As we say in my land, —Se me han puestos los pelos como escarpias— (I don't know how is it in English: [http://translate.google.es/#es/en/se%20me%20han%20puesto%20los%20pelos%20como%20escarpias]. It is a good situation).

Thank you, It runs ok.

Where can I find more information about manifiest.json? The elements and it meaning (thumbnails, apps, setup, teardown, assets, files, etc).
And finally, Is there more information/documentation about foxx?

I have looking mcacki/aye_aye example, and in repositories/todos.js code var _ = require("underscore"); to use external modules. Is this the way to import others useful modules or it is only valid for underscore? 

Lucas Dohmen

unread,
May 23, 2013, 4:27:47 AM5/23/13
to aran...@googlegroups.com, Andrés Orencio Ramírez Pérez, j.ste...@triagens.de
Hey Andrés,

Jan already answered most of your questions :) You can find the documentation for Foxx here: http://www.arangodb.org/manuals/current/UserManualFoxx.html
Just search for "The Manifest File" there, you will find an entire section about this topic.

Modules:
Underscore is built-in ;) You can also use other Node Modules from NPM as well. But be aware that we do not support (and do not want to support) the entire functionality of node, so there are a lot of packages that won't work with ArangoDB. A good rule of thumb is: If it runs in both the browser and node, it will run in ArangoDB. You can find more information about this topic here:

If you have any trouble in understanding Foxx or the manual, please feel free to ask anything. As the author of both Foxx and the documentation, I really like to get feedback about it to improve it :)

Kind Regards,
Lucas 

Andrés Orencio Ramírez Pérez

unread,
May 23, 2013, 1:50:14 PM5/23/13
to aran...@googlegroups.com, Andrés Orencio Ramírez Pérez, j.ste...@triagens.de

Ok Lucas and thank you for the documents links.

I'm going to read it.


Reply all
Reply to author
Forward
0 new messages