0

我正在创建一个类似 Facebook 的网站,我想为在同一所学校学习但还不是朋友的用户推荐朋友。

我已经尝试使用 AQL 查询来执行此操作,但似乎存在语法问题..

错误代码返回是:

语法错误,'user._key not in (forfriend in ...' at 3:3 位置附近的意外标识符 (解析时))

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
4

1 回答 1

0

如果要应用多个过滤条件,则必须通过逻辑AND(或&&运算符)组合它们

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

或者您可以使用单独的 FILTER 子句

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
于 2020-05-27T13:32:51.853 回答