i work for a bbs app recently, and when i use the aql, i got a problem, for example:
//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:
if(params.digest) {
return `digest == true && conditions`
}
return `conditions`
i'm using javascript, please give me a direction...
You can use the function HAS(document, attributeName)
to check whether the attribute is present in the document.
FOR t IN threads
FILTER (!HAS(t,"digest") || i.digest == true) && conditions
RETURN t
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.