DEV Community

Talha Munir ๐Ÿ‡ต๐Ÿ‡ธ
Talha Munir ๐Ÿ‡ต๐Ÿ‡ธ

Posted on โ€ข Edited on

Scalar functions in Apache age

Scalar functions in Apache age are mentioned below:

id

id() returns the id of the vertex or an edge. It returns an agtype integer.

Query:

Query for usage of id is as under:

SELECT *
FROM cypher('graph_name', $$
    MATCH (a)
    RETURN id(a)
$$) as (id agtype);
Enter fullscreen mode Exit fullscreen mode

Start_id():

Start_id returns the id of the starting vertex or an edge. It also returns an agtype integer.

Query:

Query for usage of start_id() is as under

SELECT *
FROM cypher('graph_name', $$
    MATCH ()-[e]->()
    RETURN start_id(e)
$$) as (start_id agtype);
Enter fullscreen mode Exit fullscreen mode

The query returns the start id of all the vertex and edges.

end_id:

End_id returns the id of such vertex that are the ending vertexes for the edges. It also returns an agtype integer.

Query:

SELECT *
FROM cypher('graph_name', $$
    MATCH ()-[e]->()
    RETURN end_id(e)
$$) as (end_id agtype);
Enter fullscreen mode Exit fullscreen mode

Type:

Type() returns the string representation of the edge type. It returns an agtype string.

Query:

Query for the usage of type function is as below:

SELECT *
FROM cypher('graph_name', $$
    MATCH ()-[e]->()
    RETURN end_id(e)
$$) as (end_id agtype);
Enter fullscreen mode Exit fullscreen mode

Properties():

Returns an agtype map which contains all the properties of a vertex or an edge. If the argument is a map then it is returned unchanged.

Query:

Query for the usage of properties is as under.

SELECT *
FROM cypher('graph_name', $$
    CREATE (p:Person {name: 'Stefan', city: 'Berlin'})
    RETURN properties(p)
$$) as (type agtype);
Enter fullscreen mode Exit fullscreen mode

It returns the properties of the node p created in the same query.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Image of Docusign

๐Ÿ› ๏ธ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more