Other functions
In this section, we will explore the additional functions provided by GQL.
Trimming a list
As discussed earlier, the TRIM
function can be used to trim strings; it can also be applied to trim a list
value.
The trim list function removes a specified number of elements from the right end of the list.
Here is an example:
GQL:
RETURN TRIM([1,2,3,4,5], 2)
The query returns a new list with [1,2,3]
, with the last 2 elements from the right side of the list removed.
Converting a path to a list
The ELEMENTS
function converts a path
value to a list
value.
Here is an example:
GQL:
MATCH p=()-[]-() RETURN ELEMENTS(p) LIMIT 1
The query returns a list containing two nodes and one edge, instead of a path
value.
Converting a data type with CAST
GQL supports using the CAST
function to convert data to a target type explicitly.
The syntax of the CAST
function is CAST (<value> AS <target type>)
.
For example, to convert...