Last inserted _key in ArangoDB with AQL?

How can I get the last inserted _key in ArangoDB with an AQL query? I put the item in the collection, the next item should contain the item created by _key. How to get this _key?

+4
source share
2 answers

Update on this subject: Since ArangoDB 2.4 you can get a newly inserted document (or documents) even with an AQL query.

In previous versions of ArangoDB 2.3, the syntax for a single INSERT document was as follows:

INSERT { value: 1 } IN collection 

without the ability to get system attributes ( _key, _revetc.) for the document just inserted. Starting from 2.4, the following is also possible:

INSERT { value: 1 } IN collection LET result = NEW RETURN result

, (value ) .

, .

FOR i IN 1..10 
  INSERT { value: i } IN collection

FOR i IN 1..10 
  INSERT { value: i } IN collection LET result = NEW RETURN result

.

+9

, (2.3) _key AQL.

db.<collection>.save({ Hello : "World" }): _key

+2

All Articles