John
John

Reputation: 1

Is there a way to create a dynamic edge collection?

I have a collection in this format:

[
    {
        'name': 'test', 
        'features': ['features/id', 'features/id2'...]
    }
]

I want to create a dynamic edge collection which connects between documents that has the same features.
For example, if I have this collection:

[
    {
        'name': 'test', 
        'features': ['features/id', 'features/id2']
    },
    {
        'name': 'test2', 
        'features': ['features/id2']
    },
    {
        'name': 'test3', 
        'features': ['features/id']
    },
]

The edge collection will automatically create these connections: test <-> test2; test <-> test3

Upvotes: 0

Views: 250

Answers (1)

CodeManX
CodeManX

Reputation: 11915

You cannot create collections with AQL. What you can do though is to

  • use a single edge collection and store attributes such as the name on edges to filter by it later in queries
  • run a query to determine the distinct edge collection names, create an edge collection for each name via arangosh, the HTTP API or a driver and also run a query for each to create edges in the respective edge collection

Also see https://www.arangodb.com/docs/stable/graphs.html#multiple-edge-collections-vs-filters-on-edge-document-attributes

I don't think that this is what you are asking for however (see comment).

Upvotes: 0

Related Questions