简体   繁体   中英

Arango AQL queries NOT IN

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM