ArangoDB

Preparing the Examples

Some examples in the manuals assume that you have created the following collections:

  • demo
  • five
  • geo

Some of the examples may destroy the collection. In that case you can use one of the following script to restore the collection.

examples.js: A JavaScript script usable within the ArangoDB shell to regenerate the above collections.

examples.sh: A shell script using curl to setup the collections. The script works without any additional client, but will not be able to detect any errors.

Collection "demo"

avocsh> db.demo.all();
[
  { 
    _id : "161039/4323870", 
    _rev : 4323870, 
    name : "Hugo", 
    firstName : "Egon", 
    address : { 
      city : "Hier", 
      street : "Neue Strasse"
    }, 
    hobbies : [
      "swimming", 
      "programming"
    ]
  }, 

  { 
    _id : "161039/4192798", 
    _rev : 4192798, 
    hallo : "world"
  }, 

  { 
    _id : "161039/4258334", 
    _rev : 4258334, 
    world : "hallo"
  }
]

was generated by

Collection "five"

The collection "five" has a unique constraint on the attribute a, and a second unique constraint on the attribute b.

avocsh> db.five.all();
[
  { 
    _id : "138663/2631399", 
    _rev : 2631399, 
    a : 2, 
    b : "Two"
  }, 

  { 
    _id : "138663/2828007", 
    _rev : 2828007, 
    a : 5, 
    b : "Five"
  }, 

  { 
    _id : "138663/2696935", 
    _rev : 2696935, 
    a : 3, 
    b : "Three"
  }, 

  { 
    _id : "138663/2565863", 
    _rev : 2565863, 
    a : 1, 
    b : "One"
  }, 

  { 
    _id : "138663/2762471", 
    _rev : 2762471, 
    a : 4, 
    b : "Four"
  }
]

was generated by

Collection "geo"

The collection "geo" has two geo fields, one home being a list with two elements, one work being an hash array with latitude b and longitude l.

[
  { 
    _id : "154092/301894631", 
    _rev : 301894631, 
    work : { 
      b : -70, 
      l : -30
    }, 
    name : "Name/-70/-30", 
    home : [
      -70, 
      -30
    ]
  }, 

  { 
    _id : "154092/305433575", 
    _rev : 305433575, 
    work : { 
      b : -60, 
      l : 140
    }, 
    name : "Name/-60/140", 
    home : [
      -60, 
      140
    ]
  }, 

  { 
    _id : "154092/314215399", 
    _rev : 314215399, 
    work : { 
      b : -20, 
      l : 0
    }, 
    name : "Name/-20/0", 
    home : [
      -20, 
      0
    ]
  }, 
  ...
]

was generated by