0
votes

I'm creating a Facebook-like website and I want to suggest friends for a user who studies at the same school, but are not already friends.

I already Trying to do this with AQL queries, but there seems to be a syntax problem..

The error code return was:

syntax error, unexpected identifier near 'user._key not in (for friend in ...' at position 3:3 (while parsing)

for user in users
  filter user._key != "myself"
    user._key not in (for user in 1..1 outbound "users/myself" friendship return user) 
      user._key not in (for user in 1..1 outbound "users/myself" schoolStudies return user)
    return user
1

1 Answers

0
votes

If you want to apply several filter criteria you have to combine them via logical AND (or the && operator)

FOR user IN users
  FILTER user._key != "myself" AND
    user._key not in (for user in 1..1 outbound "users/myself" friendship return user) AND
    user._key not in (for user in 1..1 outbound "users/myself" schoolStudies return user)
  RETURN user

or you can use separate FILTER clauses

FOR user IN users
  FILTER user._key != "myself"
  FILTER user._key not in (for user in 1..1 outbound "users/myself" friendship return user)
  FILTER user._key not in (for user in 1..1 outbound "users/myself" schoolStudies return user)
  RETURN user