%% Update Labels and Properties for One Node
% Create a single node in a Neo4j® database, update its node labels and properties, and display them.
% Assume that you have graph data stored in a Neo4j database that represents a social neighborhood. This database has seven nodes and eight relationships. Each node has only one unique property key name with a value ranging from User1 through User7. Each relationship has the type knows.
%
% Create a Neo4j database connection using the URL http://localhost:7474/db/data, user name neo4j, and password matlab.

url = 'http://localhost:7474/db/data';
username = 'neo4j';
password = 'matlab';

neo4jconn = neo4j(url,username,password);

%
% Check the Message property of the Neo4j connection object neo4jconn. The blank Message property indicates a successful connection.

neo4jconn.Message

%
% Create a single node in the database using the Neo4j database connection.

node = createNode(neo4jconn)

%
% node is a Neo4jNode object with these properties:
% Node identifier
% Node data
% Node labels
% Create a table with one row that contains data about a person. Specify the name and job title of the person.

properties = table("User8","Analyst",'VariableNames',{'Name','Title'});

%
% Update the node by adding the labels Person and Employee and the node properties defined in the table.

labels = ["Person","Employee"];
updateNode(neo4jconn,node,'Labels',labels, ...
    'Properties',properties)

%
% Display the updated node labels. nodeinfo is a Neo4jNode object.

nodeid = node.NodeID;
nodeinfo = searchNodeByID(neo4jconn,nodeid);
nodeinfo.NodeLabels

%
% Display the updated node properties.

nodeinfo.NodeData

%
% Close the database connection.

close(neo4jconn)

%
% Copyright 2018 The MathWorks, Inc.