Alias exists to name the data generated during the execution of UQL, so that the data can be called subsequently.
Custom Alias
A custom alias is defined using keyword as
as soon as the data is generated. A data can be re-defined with different aliases, but only the last defined alias is valid. An alias can only be defined once, even though its data could be re-defined with another alias later, this alias will be considered obsolete and cannot be used for defining other data.
Naming Conventions
Avoid using property names as alias (and use system alias this
to disambiguate when necessary), must be using:
- 1 ~ 64 characters
- Not allow to start with wave line '~'
- Not allow to contain back quote '`'
- Not allow to use system reserved words
- (When containing characters other than letters, numbers and underscore, the alias name should be wrapped with backquote '`' when being used in the UQL)
Examples of Defining Alias
When aliases contain only letters, numbers and underscore:
Example | Alias in Example |
---|---|
find().nodes() as nodes | nodes |
find().edges() as edges | edges |
n().e().n() as paths | paths |
with table(nodes.name, nodes.birthday) as user_list | user_list |
with nodes.birthday as date_of_birth | date_of_birth |
When aliases contain special characters:
with [1,2,3] as `my-list`
return `my-list`
Omission of defining alias for a newly generated data, or defining an alias that is never called, both could induce negative effect on the validity of UQL.
System Alias
System Alias |
Where to Call | Data Represented |
---|---|---|
this |
In any filter | Current node or edge |
prev_n |
In the filter of node/edge template | The previous node of the current node or edge |
prev_e |
In the filter of node/edge template | The previous edge of the current node or edge |
this
In practical this
is rarely used unless to eliminate any ambiguity. Ambiguity occurs when calling a property whose name corresponds with an active custom alias, in which case this
has to be used to refer to the property of node/edge.
The node filter {this.balance > 5000}
in below code describes 'the balance of current node should be greater than 5,000':
... as balance
find().nodes({this.balance > 5000})
Since node property balance corresponds with alias balance defined in the first statement, omitting this
from the filter, which becomes {balance > 5000}
such that the description turns into 'alias balance should be greater than 5,000', obviously is not a reasonable filtering condition.
prev_n
prev_n
only appears in templates.
- For single node/edge template:

- For multi-edge template:

For the initial-node of a path, whose
prev_n
does not exist, the judgements of==
,!=
,>
,>=
,<
,<=
involving itsprev_n
will returntrue
by default, while the judgements of other operators are unpredictable.
prev_e
prev_e
only appears in templates.
- For single node/edge template:

- For multi-edge template:

For the initial-node and the first edge of a path, whose
prev_e
does not exist, the judgements of==
,!=
,>
,>=
,<
,<=
involving theirprev_e
will returntrue
by default, while the judgements of other operators are unpredictable.
Call an Alias
Suppose that nodes, edges, paths, mylist, mypoint, myobject and myitem are aliases of type NODE, EDGE, PATH, list, point, object and others, below call formats are supported:
Call Format |
Call Content | Call Type |
---|---|---|
nodes |
Node | NODE |
nodes.<property> |
Node property | The type of this property (prompt error if property does not exist) |
nodes.@ |
Node schema | string |
edges |
Edge | EDGE |
edges.<property> |
Edge property | The type of this property (prompt error if property does not exist) |
edges.@ |
Edge schema | string |
paths |
Path | PATH |
mylist |
The whole list | list |
mylist[n] |
The element with index n | The type of this element |
mylist[n1:n2] |
A sub-list formed by element with index n1~n2 | list |
mylist[:n] |
A sub-list formed by element with index 0~n | list |
mylist[n:] |
A sub-list formed by element with index n~<length-1> | list |
mypoint |
The whole coordinates | point |
mypoint.x |
The coordinate x | double |
mypoint.y |
The coordinate y | double |
myobject.a |
The key a | The type of this key |
myitem |
The value | The type of this value |
Type TABLE is not supported to be called in UQL. Regarding how to specify a valid return format in RETURN clause, please read the table at the end of documentation RETURN.