I have created this vertex:
test=# SELECT * FROM cypher('graph', $$
CREATE (s:student{name:"Muneeb", courses: ["OOP", "DS", "Programming", "Android"]})
RETURN s
$$) as (student agtype);
----------------------------------------------------------------------------------------
student
----------------------------------------------------------------------------------------
{"id": 3377699720527873, "label": "student", "properties": {"name": "Muneeb", "courses": ["OOP", "DS", "Programming", "Android"]}}::vertex
(1 row)
I want to get the length of courses
List. How can I do that.
I tried ARRAY_LENGTH
but it didn’t work.
3
Answers
You can use size function.
Result
In addition to taha answer, You can also use jsonb_array_length:
The example code for this
Th output will be:
For this you can use size function
size() returns the length of a list.
here is the query
SELECT * FROM cypher(‘graph_name_here’, $$
MATCH (u)
RETURN size(u.name_of_list_you_want_size)
$$) as (student agtype);
or
this is from age documentation link of documentation is official documentation link