Is there a way to use dynamic collection names in AQL?

1.1k views Asked by At

If I have a collection that contains collection names in it, is there a syntax in AQL that allows you to use dynamic collection names?

Here is an example of what I'm looking for. A collection called master has many documents, with a .state of Active or Disabled. The collection has a key called collection_name which is the name of another collection in this database.

FOR doc IN master 
FILTER doc.state == 'Active' 
    FOR c IN COLLECTION(doc.collection_name)    <--- invented command called COLLECTION
    RETURN {
      'collection_name': doc.collection_name,
      'contents': c
    }

I'm trying to retrieve all documents from all collections marked as Active in the master collection.

Is there a way to do this in one AQL query without having to break it up into an initial query on master followed by n queries for each of the collections returned?

1

There are 1 answers

0
felixlinker On BEST ANSWER

As I've concluded from this ArangoDB issue there is no way to truly use dynamic collection names.

However you could use any AQL function as workaround. See the last comment on the issue for a full explanation.