ArangoDB Arango AQL查询不在

qltillow  于 2022-12-09  发布在  Go
关注(0)|答案(1)|浏览(178)

我正在创建一个类似Facebook的网站,我想为在同一所学校学习但还不是朋友的用户推荐朋友。
我已经在尝试使用AQL查询来完成此操作,但似乎存在语法问题。
返回的错误代码为:
语法错误,位置3处的“user._key not in(for friend in ...”附近出现意外的标识符: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
o75abkj4

o75abkj41#

如果您想应用多个过滤条件,则必须通过逻辑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

相关问题