0

I am going through the tutorial on Arangodb which is using a sample game of thrones dataset. I am trying to figure out how I would be able to filter out characters based on a trait?

 INSERT {
    "name": "Ned",
    "surname": "Stark",
    "alive": true,
    "age": 41,
    "traits": ["A","H","C","N","P"]
} INTO Characters

I am trying to use the following code but its not working. Would the above traits be an array. if so how do I proceed?

for c in Characters
Filter c.traits =="A"
RETURN c

Thank you!

1 Answer 1

1

If you want to find all characters that have trait "A" you can use FILTER "A" IN c.traits, i.e., the characters may also have other traits. If you want to find characters that have only trait "A" you can use FILTER c.trait == ["A"].

Sign up to request clarification or add additional context in comments.

2 Comments

Suppose I wanted to filter characters with A and M? FILTER "A" AND "M" in c.traits is giving me an error
You can use ALL IN - see arangodb.com/docs/stable/aql/…

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.