1

I know that in ArangoDB, you can use the below structure to iterate over all the attributes in a document:

FOR doc IN collection 
  LET attrs = ATTRIBUTES(doc)  

I would like to do something similar, however I would like to ignore attributes that don't have array values, that is I only want to iterate over key-values where the value is an array (not a string, object, etc.) Is it possible to filter the attributes out this way, and if so how?

1 Answer 1

4

ATTRIBUTES() does not return all attributes in a document, but only the top-level attributes to be precise.

If you are interested in top-level attributes whose value is of type array, then you can do the following to get their attribute keys:

FOR doc IN collection
  LET attrs = (
    FOR att IN ATTRIBUTES(doc)
      FILTER IS_ARRAY(doc[att])
      RETURN att
  )
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.