Functions
LatticeDB supports the following built-in functions in Cypher expressions.
id()
Returns the internal ID of a node:
MATCH (n:Person)
RETURN id(n), n.name
coalesce()
Returns the first non-null argument:
MATCH (n:Person)
RETURN coalesce(n.nickname, n.name) AS display_name
abs()
Returns the absolute value of a number:
MATCH (n:Person)
RETURN n.name, abs(n.score) AS abs_score
size()
Returns the length of a list:
MATCH (p:Person)-[:KNOWS]->(f:Person)
WITH p, collect(f) AS friends
RETURN p.name, size(friends) AS friend_count
toInteger()
Converts a value to an integer:
MATCH (n:Person)
RETURN n.name, toInteger(n.score) AS int_score
toFloat()
Converts a value to a float:
MATCH (n:Person)
RETURN n.name, toFloat(n.age) AS float_age
Type Coercion
Numeric operations automatically promote integers to floats when mixed:
RETURN 42 + 3.14 -- Returns 45.14 (float)
Null propagates through most operations:
RETURN null + 1 -- Returns null
RETURN null = null -- Returns true (special case)