I want to add array of elements to a node in Neo4j graph databse. The structure of node what I want is illustrated below.
User[0]
id : 123
name : [firstname:'abc',lastname:'pqr']
or
User[0]
id :123
name :[abc,pqr]
anyone please help.
I want to add array of elements to a node in Neo4j graph databse. The structure of node what I want is illustrated below.
User[0]
id : 123
name : [firstname:'abc',lastname:'pqr']
or
User[0]
id :123
name :[abc,pqr]
anyone please help.
You can store arrays directly in Neo4j, Maps not yet, but if the structure is the same you can put the map values into an array.
But I'd rather split out your "name" field into "firstname" and "lastname" in the graph node.
You can use Maps (Key-Value Pairs) for this purpose:
CREATE (u:User {id: 123, name: {firstname: 'abc', lastname: 'pqr'}})
Using a List:
CREATE (u:User {id: 123, name: ['abc', 'pqr']})
To Update Use
MATCH (u:User {id: 123})
SET u.name = {firstname: 'new_firstname', lastname: 'new_lastname'}
Hopefully this will work out for you.