Skip to content

Instantly share code, notes, and snippets.

@solisoft
Created March 5, 2019 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solisoft/b294dce463b053dd8e4c1f8f94b7f84b to your computer and use it in GitHub Desktop.
Save solisoft/b294dce463b053dd8e4c1f8f94b7f84b to your computer and use it in GitHub Desktop.
ArangoDB / AQL : reorder collection
LET docs = (FOR doc IN @@collection SORT doc._key RETURN doc)
FOR i IN (0..(LENGTH(docs) - 1))
LET doc = docs[i]
UPDATE({ _key: doc._key, order: i }) IN @@collection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment