1

I would like to prepare scripts for completing databases. How can I do this?

Something like that:

 INSERT { _class: 'Entity', name: 'First'} IN wholesales
 INSERT { _class: 'Entity', name: 'Second' } IN wholesales
 INSERT { _class: 'Entity', name: 'Three' } IN wholesales
 INSERT { _class: 'Entity', name: 'Four' } IN wholesales

1 Answer 1

2

Only one INSERT operation per collection and query is allowed in AQL.

You can use a loop to make this work however:

FOR doc IN [
    { _class: 'Entity', name: 'First'},
    { _class: 'Entity', name: 'Second' },
    { _class: 'Entity', name: 'Third' },
    { _class: 'Entity', name: 'Fourth' }
]
INSERT doc INTO wholesales

The documents as well as the collection name can also be passed as bind parameters.

Query:

FOR doc IN @docs INSERT doc INTO @@coll

Bind parameters:

{ "docs": [ { ... }, { ... } ], "@coll": "wholesales" }

Another way to import data is to use arangoimport.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.