1
votes

As I understand it, the arangoimp function can import an array of documents into a new collection.

As I have the output of complex join in the form of an array of documents that I would like to create as a new collection. Given this, is there a way to execute arangoimp on the array either as part of the query or, say, arangosh?

Otherwise, my options are: 1) Just suck it up and iterate through the array and save the documents; or 2) Dump the array to a file and import using arangoimp...

Maybe I'm missing something obvious here but I have a bit of time this week trying work out an answer. All thoughts or suggestions gratefully received.

1
is your join on ArangoDB or in a legacy db? In ArangoDB you can for sure directly insert the joined documents into a new collection. - dothebart
@Guido: does your input data reside in ArangoDB, or do you want to import it from another DBMS? - CodeManX
The data I wanted is in a text file that I wanted to load and run a transformation during the import. The file is big enough to be mildly irritating (~1GB) but my work around was to import into a temporary collection, run a query to create the new collection and drop the temporary collection... - Guido

1 Answers

0
votes

as I understand and correct me if I’m wrong, you want to make it automated. First it will execute the complex join and then will store output array in a new collection.

So based on that , you can write code using arangojs driver.

  Database = require('arangojs').Database;
  db = new Database({url:'http://myapp:_password_@myappserver:8529',databaseName:'myapp-db'});
    var collection = db.collection(collectionName);
    db.query(yourQuery).then(cursor=> {
                return cursor.all();
                 }).then(list =>{
                  collection.import(list);
                });

I haven't tested the code. you can find more here Bulk importing documents