What is the best method for filtering graph graphs by type in AQL

I have the following super simple graph: picture of graph

What I'm trying to do is:

  • Select all questions that have a property in the firstQuestion question document with a value of true.
  • Select any options related to the question using the outgoing edge of type with_options

The following query works, however it seems that there should be a better way to check the edge type without using string operations - in particular, the concatenation operation that I use to recreate the value of edge _id by combining it with the key with the edge type I want - this is the best way check the type of rib?

FOR question IN questions 
FILTER question.firstQuestion == true
    let options = 
        (FOR v, e IN 1..1 OUTBOUND question._id GRAPH 'mygraph'
        FILTER CONCAT('with_options/', e._key) == e._id
        RETURN v)
RETURN {question: question, options: options}
+4
source share
1 answer

IS_SAME_COLLECTION ArangoDB 2.8.1. DOCUMENT .

FOR question IN questions 
  FILTER question.firstQuestion == true
  LET options = (FOR v, e IN 1..1 OUTBOUND question._id GRAPH 'mygraph'
                   FILTER IS_SAME_COLLECTION('with_options', e._id)
                     RETURN v)
  RETURN {question: question, options: options}

, , :

FOR question IN questions 
  FILTER question.firstQuestion == true
  LET options = (FOR v, e IN 1..1 OUTBOUND question._id with_options RETURN v)
  RETURN {question: question, options: options}
+2

Source: https://habr.com/ru/post/1626433/


All Articles