1

Is there a simple way to move documents between collections in ArangoDB? I tried the cheap approach to just alter the _id, but as feared that's not supposed to be done or possible:

FOR i IN collection_A
UPDATE { _key: i._key, _id: CONCAT('collection_B/',i._key) } IN collection_A

Are there useful ways how I can move my document from collection_A to collection_B with AQL?

Qohelet
  • 1,459
  • 4
  • 24
  • 41

3 Answers3

4

You could try something like

FOR i IN collection_A
    LET i_b = UNSET(i, "_id") // Remove the id that is not valid before insert
    INSERT i_b INTO collection_B
    REMOVE i IN collection_A
darkheir
  • 8,844
  • 6
  • 45
  • 66
  • Gladly upvote as it's working code which helps. Yet I'm rather curious if there's some quicker or more efficient way – Qohelet Oct 03 '19 at 09:35
0

Just do an insert instead of an update For I in collection_A Insert into collection_B

camba1
  • 1,795
  • 2
  • 12
  • 18