Skip to Content

Array<T> data type

An array is an ordered collection of values of the same type, denoted by Array<T> where T represents the type of elements in the array.

ℹ️

Array indices in Cypher start from 0. For example, in the array [1, 2, 3], the first element 1 is accessed using index 0.

Example

-- Define an vertex table with array type as column CREATE VERTEX person ( id BIGINT, name VARCHAR, hobbies ARRAY<VARCHAR> ) PRIMARY KEY id;

Array literals

Array literals in Cypher are used to define arrays directly within queries. They are created using square brackets [] and can contain a list of values separated by commas. Each value in the array must be of the same data type.

Examples

-- Define an array of integers RETURN [1, 2, 3, 4, 5] AS integerArray; -- Define an array of strings RETURN ['apple', 'banana', 'cherry'] AS stringArray; -- Define a nested array RETURN [[1, 2], [3, 4], [5, 6]] AS nestedArray;
Last updated on