J@ArangoDB

{ "subject" : "ArangoDB", "tags": [ "multi-model", "nosql", "database" ] }

Small Things in 2.8: Collection Type for Arangoimp

When trying to import data into ArangoDB from a JSON or CSV file using the arangoimp binary, there is always the chance that the target collection does not yet exist.

In order to create a missing target collection arangoimp for long has provided the option --create-collection true:

importing, optionally creating a missing collection
1
2
3
4
arangoimp                       \
  --file users.json             \
  --collection users            \
  --create-collection true

However there hasn’t been a way of specifying the type for the target collection, so the new collection was always created as document collection.

To import data into an edge collection, the target collection needed to be created by another means, e.g. by using the ArangoShell. It would have been more handy if arangoimp were able to create edge collections too.

2.8 finally adds that feature, and it’s simple to use: to create an edge collection if the target collection does not exist, append the --create-collection-type edge option when invoking arangoimp:

importing, optionally creating a missing edge collection
1
2
3
4
5
arangoimp                       \
  --file users.json             \
  --collection users            \
  --create-collection true      \
  --create-collection-type edge