FILTER for entry in list of objects in AQL (ArangoDB)



Just a quick blag for my future self: ``` FOR row IN coll FOR entry in doc.array FILTER entry.field_name != @field_name LIMIT @limit RETURN DISTINCT doc ``` Didn't give me what I wanted. While slapping `DISTINCT` on the `RETURN` fixed the problem of "I'm getting the same document over and over again" it now doesn't return `@limit` many documents but seemingly a random — but lower — number. What's actually happening here is, that the indentation is deceiving: the last two lines should be indented one more. ``` FOR row IN coll FILTER POSITION(doc.array[*].field_name , @field_name) == false LIMIT @limit RETURN doc ``` Is what I _actually_ wanted. Edit (2023-04-18): And _now_ I learned that you should actually do this: ``` FOR row IN coll FILTER @field_name NOT IN doc.array[*].field_name LIMIT @limit RETURN doc ```

Leave a Reply

Your email address will not be published. Required fields are marked *