WHERE can keep the rows in the data stream that meet the conditions, and discard those that do not meet the conditions.
Syntax 1: WHERE <condition>
Syntax 2: WHERE <query>
(Under development)
Input
- <condition>: Judgement conditions, rows that are judged as TRUE will be kept
- <query>: Query statement, rows that have return will be kept
The clause or chain statement after WHERE must process the alias appeared in WHERE or the homologous alias of that alias, otherwise the clause or chain statement will not be executed.
find().nodes({shape == "square"}) as n1
find().nodes({shape == "round"}) as n2
where n1.color == n2.color
return n1, n2
In the UQL above, WHERE trims the n1 and n2 to 3 rows as they are heterologous, then filter each row:
WHERE <condition>
Example: find three-step transfer paths from Card CA001 to Card CA002, with two intermediate cards in the paths containing at least one card whose level is 5
n({_id == "CA001"}).e().n({@card} as n1)
.e().n({@card} as n2)
.e().n({_id == "CA002"}) as p
where n1.level == 5 || n2.level == 5
return p{*}
WHERE <query>
(Under Development)
Example: find an intermediate card with alias 'agent' that satisfies conditions as shown in the image below: Card CA002 transfers money to Card CA001 via agent; agent is a neighbor to Card CA003 within 2 hops
n({_id == "CA002"}).re().n({@card} as agent).re().n({_id == "CA001"})
where n(agent).e()[*:2].n({_id == "CA003"})
return agent{*}
Analysis: WHERE further filters data columns "agent": it judges if the shortest paths from "agent" to Card CA003 exist, if true, then it passes "agent" to later "return"
The example above can be put in a subgraph template as shown below:
graph([
n({_id == "CA002"}).re().n({@card} as agent).re().n({_id == "CA001"}),
n(agent).e()[*:2].n({_id == "CA003"})
])
return agent{*}