Create documents
ArangoDB's official AQL docs for INSERT can be found here
Autogenerated keys
Create an empty document using the following AQL query:
insert {} into scratch return NEW
The AQL query above creates and empty document, ArangoDB auto-generates the key
The return NEW is optional, it returns the document that was created. Note: The keyword NEW needs to be in capital case
You can view the results in either JSON or Table format
- Table format:
- JSON format:
You can also run the AQL query below, the created document will not be returned:
insert {} into scratch
You can also create a document with additional attributes/fields (without specifying an _key), ArangoDB auto-generates the key
insert {'field1': 'foo', 'field2': 'bar'} into scratch return NEW
The following query is analogous to the previous query, quotes are not required 1 on the field names however are required on string values
insert {field1: 'foo', field2: 'bar'} into scratch return NEW
- 1 Unless there are spaces or special characters in the field names
- The following query will error / fail
insert {field1: 'foo', field2: bar, field 3: 'baz'} into scratch return NEW
- The following corrected query will succeed
insert {field1: 'foo', field2: 'bar', 'field 3': 'baz'} into scratch return NEW
- The following query will error / fail
Explicit keys
- You can explicitly specify the keys:
insert {'_key': 'foo-bar', field1': 'foo', 'field2': 'bar'} into scratch return NEW
Anything unclear or buggy in this tutorial? Provide Feedback