简体   繁体   English

arangoDB aql是否可以按条件跳过过滤器?

[英]can arangoDB aql skip filters by condition?

i work for a bbs app recently, and when i use the aql, i got a problem, for example: 我最近为bbs应用程序工作,当我使用aql时,出现问题,例如:

//params:.com/t/123?&digest=true
=>
  FOR t IN threads
    FILTER t.digest == true && some conditions
    RETURN t

and the result is as expected,but when the parameter 'digest' is undefined or false, i want it returns all the threads..not which 'digest' = false, so i have to use if...else to write two almost same code, just remove the condition 't.digest == true' for example: 结果是预期的,但是当参数“ digest”未定义或为false时,我希望它返回所有线程。不是哪个“ digest” = false,因此我必须使用if ... else来写两个相同的代码,只需删除条件“ t.digest == true”,例如:

if(params.digest) {
  return `digest == true && conditions`
} 
return `conditions`

i'm using javascript, please give me a direction... 我正在使用javascript,请给我一个方向...

You can use the function HAS(document, attributeName) to check whether the attribute is present in the document. 您可以使用函数HAS(document, attributeName)来检查HAS(document, attributeName)是否存在该属性。

FOR t IN threads
  FILTER (!HAS(t,"digest") || i.digest == true) && conditions
  RETURN t

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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